class_docstr: Implements NAttack: https://arxiv.org/abs/1905.00441
  
  Disclaimers: Note that NAttack assumes the model outputs
  normalized probabilities.  Moreover, computations are broadcasted,
  so it is advisable to use smaller batch sizes when nb_samples is
  large.
  
  Hyperparams: sigma controls the variance for the generation of
  perturbations.
  
  :param predict: forward pass function.
  :param eps: maximum distortion.
  :param order: the order of maximum distortion (inf or 2)
  :param loss_fn: loss function (default None, NAttack uses CW loss)
  :param nb_samples: population size (default 100)
  :param nb_iter: number of iterations (default 40)
  :param eps_iter: attack step size (default 0.02)
  :param sigma: variance to control sample generation (default 0.1)
  :param clip_min: mininum value per input dimension (default 0.)
  :param clip_max: mininum value per input dimension (default 1.)
  :param targeted: if the attack is targeted (default False)
class_docstr_tok: ["Implements","NAttack",":","https",":","\/\/arxiv.org\/abs\/1905.00441","Disclaimers",":","Note","that","NAttack","assumes","the","model","outputs","normalized","probabilities",".","Moreover",",","computations","are","broadcasted",",","so","it","is","advisable","to","use","smaller","batch","sizes","when","nb_samples","is","large",".","Hyperparams",":","sigma","controls","the","variance","for","the","generation","of","perturbations",".",":","param","predict",":","forward","pass","function",".",":","param","eps",":","maximum","distortion",".",":","param","order",":","the","order","of","maximum","distortion","(","inf","or","2",")",":","param","loss_fn",":","loss","function","(","default","None",",","NAttack","uses","CW","loss",")",":","param","nb_samples",":","population","size","(","default","100",")",":","param","nb_iter",":","number","of","iterations","(","default","40",")",":","param","eps_iter",":","attack","step","size","(","default","0.02",")",":","param","sigma",":","variance","to","control","sample","generation","(","default","0.1",")",":","param","clip_min",":","mininum","value","per","input","dimension","(","default","0",".",")",":","param","clip_max",":","mininum","value","per","input","dimension","(","default","1",".",")",":","param","targeted",":","if","the","attack","is","targeted","(","default","False",")"]
code: def __init__(
      self,
      predict,
      eps: float,
      order,
      loss_fn=None,
      nb_samples=100,
      nb_iter=40,
      eps_iter=0.02,
      sigma=0.1,
      clip_min=0.0,
      clip_max=1.0,
      targeted: bool = False,
  ):
      if loss_fn is not None:
          import warnings
  
          warnings.warn(
              "This Attack currently do not support a different loss"
              " function other than the default. Setting loss_fn manually"
              " is not effective."
          )
  
      super().__init__(predict, cw_log_loss, clip_min, clip_max)
      self.eps = eps
      self.order = order
      self.nb_samples = nb_samples
      self.nb_iter = nb_iter
      self.eps_iter = eps_iter
      self.sigma = sigma
      self.targeted = targeted
  
imports: from math import inf
  from typing import Optional
  import torch
  import torch.nn.functional
  from advertorch.attacks.base import Attack
  from advertorch.attacks.base import LabelMixin
  from .utils import _check_param, _flatten, _make_projector
  from advertorch.utils import to_one_hot
label_desc: Use image node_id 1 to create a new NAttack object from inherited base classes: Attack, LabelMixin with example: obj = NAttack(predict, eps, order, loss_fn, nb_samples, nb_iter, eps_iter, sigma, clip_min, clip_max, targeted)