def mifgsm_attack(self, input, data_grad):
        """
        FGSM - This function generate the perturbation to the input.

        :param input: Data that we want to apply the perturbation
        :param data_grad: Gradient of those samples

        :return: Attacked input
        """
        pert_out = input
        alpha = self.epsilon_fgsm / self.iter_fgsm
        g = 0
        for i in range(self.iter_fgsm - 1):
            g = self.decay_factor_fgsm * g + data_grad / torch.norm(data_grad, p=1)
            pert_out = pert_out + alpha * torch.sign(g)
            pert_out = torch.clamp(pert_out, 0, 1)
            if torch.norm((pert_out - input), p=float("inf")) > self.epsilon_fgsm:
                break
        return pert_out

        FGSM - This function generate the perturbation to the input.

        :param input: Data that we want to apply the perturbation
        :param data_grad: Gradient of those samples

        :return: Attacked input
        
avalanche/training/plugins/rar.py