class_docstr: The Carlini and Wagner L2 Attack, https://arxiv.org/abs/1608.04644
  
  :param predict: forward pass function.
  :param num_classes: number of clasess.
  :param confidence: confidence of the adversarial examples.
  :param targeted: if the attack is targeted.
  :param learning_rate: the learning rate for the attack algorithm
  :param binary_search_steps: number of binary search times to find the
      optimum
  :param max_iterations: the maximum number of iterations
  :param abort_early: if set to true, abort early if getting stuck in local
      min
  :param initial_const: initial value of the constant c
  :param clip_min: mininum value per input dimension.
  :param clip_max: maximum value per input dimension.
  :param loss_fn: loss function
class_docstr_tok: ["The","Carlini","and","Wagner","L2","Attack",",","https",":","\/\/arxiv.org\/abs\/1608.04644",":","param","predict",":","forward","pass","function",".",":","param","num_classes",":","number","of","clasess",".",":","param","confidence",":","confidence","of","the","adversarial","examples",".",":","param","targeted",":","if","the","attack","is","targeted",".",":","param","learning_rate",":","the","learning","rate","for","the","attack","algorithm",":","param","binary_search_steps",":","number","of","binary","search","times","to","find","the","optimum",":","param","max_iterations",":","the","maximum","number","of","iterations",":","param","abort_early",":","if","set","to","true",",","abort","early","if","getting","stuck","in","local","min",":","param","initial_const",":","initial","value","of","the","constant","c",":","param","clip_min",":","mininum","value","per","input","dimension",".",":","param","clip_max",":","maximum","value","per","input","dimension",".",":","param","loss_fn",":","loss","function"]
docstr: Carlini Wagner L2 Attack implementation in pytorch.
docstr_tok: ["Carlini","Wagner","L2","Attack","implementation","in","pytorch","."]
code: def __init__(
      self,
      predict,
      num_classes,
      confidence=0,
      targeted=False,
      learning_rate=0.01,
      binary_search_steps=9,
      max_iterations=10000,
      abort_early=True,
      initial_const=1e-3,
      clip_min=0.0,
      clip_max=1.0,
      loss_fn=None,
  ):
      """Carlini Wagner L2 Attack implementation in pytorch."""
      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."
          )
  
      loss_fn = None
  
      super(CarliniWagnerL2Attack, self).__init__(
          predict, loss_fn, clip_min, clip_max
      )
  
      self.learning_rate = learning_rate
      self.max_iterations = max_iterations
      self.binary_search_steps = binary_search_steps
      self.abort_early = abort_early
      self.confidence = confidence
      self.initial_const = initial_const
      self.num_classes = num_classes
      # The last iteration (if we run many steps) repeat the search once.
      self.repeat = binary_search_steps >= REPEAT_STEP
      self.targeted = targeted
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import torch
  import torch.nn
  import torch.optim
  from advertorch.utils import calc_l2distsq
  from advertorch.utils import tanh_rescale
  from advertorch.utils import torch_arctanh
  from advertorch.utils import clamp
  from advertorch.utils import to_one_hot
  from advertorch.utils import replicate_input
  from .base import Attack
  from .base import LabelMixin
  from .utils import is_successful
label_desc: Use image node_id 1 to create a new CarliniWagnerL2Attack object from inherited base classes: Attack, LabelMixin with example: obj = CarliniWagnerL2Attack(predict, num_classes, confidence, targeted, learning_rate, binary_search_steps, max_iterations, abort_early, initial_const, clip_min, clip_max, loss_fn)