class_docstr: Perturbs the input with gradient (not gradient sign) of the loss wrt the
  input.
  
  :param predict: forward pass function.
  :param loss_fn: loss function.
  :param eps: attack step size.
  :param clip_min: mininum value per input dimension.
  :param clip_max: maximum value per input dimension.
  :param targeted: indicate if this is a targeted attack.
class_docstr_tok: ["Perturbs","the","input","with","gradient","(","not","gradient","sign",")","of","the","loss","wrt","the","input",".",":","param","predict",":","forward","pass","function",".",":","param","loss_fn",":","loss","function",".",":","param","eps",":","attack","step","size",".",":","param","clip_min",":","mininum","value","per","input","dimension",".",":","param","clip_max",":","maximum","value","per","input","dimension",".",":","param","targeted",":","indicate","if","this","is","a","targeted","attack","."]
docstr: Given examples (x, y), returns their adversarial counterparts with
  an attack length of eps.
  
  :param x: input tensor.
  :param y: label tensor.
            - if None and self.targeted=False, compute y as predicted
              labels.
            - if self.targeted=True, then y must be the targeted labels.
  :return: tensor containing perturbed inputs.
docstr_tok: ["Given","examples","(","x",",","y",")",",","returns","their","adversarial","counterparts","with","an","attack","length","of","eps",".",":","param","x",":","input","tensor",".",":","param","y",":","label","tensor",".","-","if","None","and","self.targeted=False",",","compute","y","as","predicted","labels",".","-","if","self.targeted=True",",","then","y","must","be","the","targeted","labels",".",":","return",":","tensor","containing","perturbed","inputs","."]
code: def perturb(self, x, y=None):
      """
      Given examples (x, y), returns their adversarial counterparts with
      an attack length of eps.
  
      :param x: input tensor.
      :param y: label tensor.
                - if None and self.targeted=False, compute y as predicted
                  labels.
                - if self.targeted=True, then y must be the targeted labels.
      :return: tensor containing perturbed inputs.
      """
      x, y = self._verify_and_process_inputs(x, y)
      xadv = x.requires_grad_()
      outputs = self.predict(xadv)
  
      loss = self.loss_fn(outputs, y)
      if self.targeted:
          loss = -loss
      loss.backward()
      grad = normalize_by_pnorm(xadv.grad)
      xadv = xadv + batch_multiply(self.eps, grad)
      xadv = clamp(xadv, self.clip_min, self.clip_max)
  
      return xadv.detach()
  
file_path: advertorch/advertorch/attacks/one_step_gradient.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import torch.nn
  from advertorch.utils import clamp
  from advertorch.utils import normalize_by_pnorm
  from advertorch.utils import batch_multiply
  from .base import Attack
  from .base import LabelMixin
label_desc: Use image node_id 2 for calling the GradientAttack obj's underlying member method code with example usage: obj.perturb(x, y) and returns: xadv