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 gradient of the loss function.
  
  :param z_logits: An array with the current logits.
  :param target: An array with the target class (one-hot encoded).
  :param x: An array with the original input.
  :param x_adv: An array with the adversarial input.
  :param x_adv_tanh: An array with the adversarial input in tanh space.
  :param c_weight: Weight of the loss term aiming for classification as target.
  :param clip_min: Minimum clipping value.
  :param clip_max: Maximum clipping value.
  :return: An array with the gradient of the loss function.
docstr_tok: ["Compute","the","gradient","of","the","loss","function",".",":","param","z_logits",":","An","array","with","the","current","logits",".",":","param","target",":","An","array","with","the","target","class","(","one-hot","encoded",")",".",":","param","x",":","An","array","with","the","original","input",".",":","param","x_adv",":","An","array","with","the","adversarial","input",".",":","param","x_adv_tanh",":","An","array","with","the","adversarial","input","in","tanh","space",".",":","param","c_weight",":","Weight","of","the","loss","term","aiming","for","classification","as","target",".",":","param","clip_min",":","Minimum","clipping","value",".",":","param","clip_max",":","Maximum","clipping","value",".",":","return",":","An","array","with","the","gradient","of","the","loss","function","."]
code: def _loss_gradient(
      self,
      z_logits: np.ndarray,
      target: np.ndarray,
      x: np.ndarray,
      x_adv: np.ndarray,
      x_adv_tanh: np.ndarray,
      c_weight: np.ndarray,
      clip_min: float,
      clip_max: float,
  ) -> np.ndarray:
      """
      Compute the gradient of the loss function.
  
      :param z_logits: An array with the current logits.
      :param target: An array with the target class (one-hot encoded).
      :param x: An array with the original input.
      :param x_adv: An array with the adversarial input.
      :param x_adv_tanh: An array with the adversarial input in tanh space.
      :param c_weight: Weight of the loss term aiming for classification as target.
      :param clip_min: Minimum clipping value.
      :param clip_max: Maximum clipping value.
      :return: An array with the gradient of the loss function.
      """
      if self.targeted:
          i_sub = np.argmax(target, axis=1)
          i_add = np.argmax(
              z_logits * (1 - target)
              + (np.min(z_logits, axis=1) - 1)[:, np.newaxis] * target,
              axis=1,
          )
      else:
          i_add = np.argmax(target, axis=1)
          i_sub = np.argmax(
              z_logits * (1 - target)
              + (np.min(z_logits, axis=1) - 1)[:, np.newaxis] * target,
              axis=1,
          )
  
      loss_gradient = self.estimator.class_gradient(x_adv, label=i_add)
      loss_gradient -= self.estimator.class_gradient(x_adv, label=i_sub)
      loss_gradient = loss_gradient.reshape(x.shape)
  
      c_mult = c_weight
      for _ in range(len(x.shape) - 1):
          c_mult = c_mult[:, np.newaxis]
  
      loss_gradient *= c_mult
      loss_gradient += 2 * (x_adv - x)
      loss_gradient *= clip_max - clip_min
      loss_gradient *= (1 - np.square(np.tanh(x_adv_tanh))) / (
          2 * self._tanh_smoother
      )
  
      return loss_gradient
  
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 3 for calling the CarliniL2Method obj's underlying member method code with example usage: obj._loss_gradient(z_logits, target, x, x_adv, x_adv_tanh, c_weight, clip_min, clip_max) and returns: loss_gradient