class_docstr: The L_2 optimized attack of Carlini and Wagner (2016). This attack is among the most effective and should be used
  among the primary attacks to evaluate potential defences. A major difference wrt to the original implementation
  (https://github.com/carlini/nn_robust_attacks) is that we use line search in the optimization of the attack
  objective.
  
  | Paper link: https://arxiv.org/abs/1608.04644
docstr: Compute the objective function value.
  
  :param x: An array with the original input.
  :param x_adv: An array with the adversarial input.
  :param target: An array with the target class (one-hot encoded).
  :param c_weight: Weight of the loss term aiming for classification as target.
  :return: A tuple holding the current logits, l2 distance and overall loss.
docstr_tok: ["Compute","the","objective","function","value",".",":","param","x",":","An","array","with","the","original","input",".",":","param","x_adv",":","An","array","with","the","adversarial","input",".",":","param","target",":","An","array","with","the","target","class","(","one-hot","encoded",")",".",":","param","c_weight",":","Weight","of","the","loss","term","aiming","for","classification","as","target",".",":","return",":","A","tuple","holding","the","current","logits",",","l2","distance","and","overall","loss","."]
code: def _loss(
      self,
      x: np.ndarray,
      x_adv: np.ndarray,
      target: np.ndarray,
      c_weight: np.ndarray,
  ) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
      """
      Compute the objective function value.
  
      :param x: An array with the original input.
      :param x_adv: An array with the adversarial input.
      :param target: An array with the target class (one-hot encoded).
      :param c_weight: Weight of the loss term aiming for classification as target.
      :return: A tuple holding the current logits, l2 distance and overall loss.
      """
      l2dist = np.sum(
          np.square(x - x_adv).reshape(x.shape[0], -1), axis=1
      )
      z_predicted = self.estimator.predict(
          np.array(x_adv, dtype=ART_NUMPY_DTYPE),
          logits=True,
          batch_size=self.batch_size,
      )
      z_target = np.sum(z_predicted * target, axis=1)
      z_other = np.max(
          z_predicted * (1 - target)
          + (np.min(z_predicted, axis=1) - 1)[:, np.newaxis] * target,
          axis=1,
      )
  
      # The following differs from the exact definition given in Carlini and Wagner (2016). There (page 9, left
      # column, last equation), the maximum is taken over Z_other - Z_target (or Z_target - Z_other respectively)
      # and -confidence. However, it doesn't seem that that would have the desired effect (loss term is <= 0 if and
      # only if the difference between the logit of the target and any other class differs by at least confidence).
      # Hence the rearrangement here.
  
      if self.targeted:
          # if targeted, optimize for making the target class most likely
          loss = np.maximum(
              z_other - z_target + self.confidence, np.zeros(x.shape[0])
          )
      else:
          # if untargeted, optimize for making any other class most likely
          loss = np.maximum(
              z_target - z_other + self.confidence, np.zeros(x.shape[0])
          )
  
      return z_predicted, l2dist, c_weight * loss + l2dist
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Optional, Tuple, TYPE_CHECKING
  import numpy
  from tqdm.auto import trange
  from art.config import ART_NUMPY_DTYPE
  from art.optimizers import Adam
  from art.estimators.estimator import BaseEstimator
  from art.estimators.classification.classifier import ClassGradientsMixin
  from art.attacks.attack import EvasionAttack
  from art.utils import compute_success, get_labels_np_array, tanh_to_original, original_to_tanh
  from art.utils import check_and_transform_label_format
label_desc: Use image node_id 2 for calling the CarliniL2Method obj's underlying member method code with example usage: obj._loss(x, x_adv, target, c_weight) and returns: z_predicted,  l2dist,  unknown