class_docstr: The black-box zeroth-order optimization attack from Pin-Yu Chen et al. (2018). This attack is a variant of the
  C&W attack which uses ADAM coordinate descent to perform numerical estimation of gradients.
  
  | Paper link: https://arxiv.org/abs/1708.03999
class_docstr_tok: ["The","black-box","zeroth-order","optimization","attack","from","Pin-Yu","Chen","et","al",".","(","2018",")",".","This","attack","is","a","variant","of","the","C","&","W","attack","which","uses","ADAM","coordinate","descent","to","perform","numerical","estimation","of","gradients",".","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1708.03999"]
docstr: Generate adversarial examples for a batch of inputs with a specific batch of constants.
  
  :param x_batch: A batch of original examples.
  :param y_batch: A batch of targets (0-1 hot).
  :param c_batch: A batch of constants.
  :return: A tuple of best elastic distances, best labels, best attacks.
docstr_tok: ["Generate","adversarial","examples","for","a","batch","of","inputs","with","a","specific","batch","of","constants",".",":","param","x_batch",":","A","batch","of","original","examples",".",":","param","y_batch",":","A","batch","of","targets","(","0-1","hot",")",".",":","param","c_batch",":","A","batch","of","constants",".",":","return",":","A","tuple","of","best","elastic","distances",",","best","labels",",","best","attacks","."]
code: def _generate_bss(
      self,
      x_batch: np.ndarray,
      y_batch: np.ndarray,
      c_batch: np.ndarray,
  ) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
      """
      Generate adversarial examples for a batch of inputs with a specific batch of constants.
  
      :param x_batch: A batch of original examples.
      :param y_batch: A batch of targets (0-1 hot).
      :param c_batch: A batch of constants.
      :return: A tuple of best elastic distances, best labels, best attacks.
      """
  
      x_orig = x_batch.astype(ART_NUMPY_DTYPE)
      fine_tuning = np.full(x_batch.shape[0], False, dtype=bool)
      prev_loss = 1e6 * np.ones(x_batch.shape[0])
      prev_l2dist = np.zeros(x_batch.shape[0])
  
      # Resize and initialize Adam
      if self.use_resize:
          x_orig = self._resize_image(
              x_orig, self._init_size, self._init_size, True
          )
          assert (x_orig != 0).any()
          x_adv = x_orig.copy()
      else:
          x_orig = x_batch
          self._reset_adam(np.prod(self.estimator.input_shape).item())
          if x_batch.shape == self._current_noise.shape:
              self._current_noise.fill(0)
          else:
              self._current_noise = np.zeros(
                  x_batch.shape, dtype=ART_NUMPY_DTYPE
              )
          x_adv = x_orig.copy()
  
      # Initialize best distortions, best changed labels and best attacks
      best_dist = np.inf * np.ones(x_adv.shape[0])
      best_label = -np.inf * np.ones(x_adv.shape[0])
      best_attack = np.array([x_adv[i] for i in range(x_adv.shape[0])])
  
      for iter_ in range(self.max_iter):
          logger.debug(
              "Iteration step %i out of %i", iter_, self.max_iter
          )
  
          # Upscaling for very large number of iterations
          if self.use_resize:
              if iter_ == 2000:
                  x_adv = self._resize_image(x_adv, 64, 64)
                  x_orig = zoom(
                      x_orig,
                      [
                          1,
                          x_adv.shape[1] / x_orig.shape[1],
                          x_adv.shape[2] / x_orig.shape[2],
                          x_adv.shape[3] / x_orig.shape[3],
                      ],
                  )
              elif iter_ == 10000:
                  x_adv = self._resize_image(x_adv, 128, 128)
                  x_orig = zoom(
                      x_orig,
                      [
                          1,
                          x_adv.shape[1] / x_orig.shape[1],
                          x_adv.shape[2] / x_orig.shape[2],
                          x_adv.shape[3] / x_orig.shape[3],
                      ],
                  )
  
          # Compute adversarial examples and loss
          x_adv = self._optimizer(x_adv, y_batch, c_batch)
          preds, l2dist, loss = self._loss(
              x_orig, x_adv, y_batch, c_batch
          )
  
          # Reset Adam if a valid example has been found to avoid overshoot
          mask_fine_tune = (
              (~fine_tuning)
              & (loss == l2dist)
              & (prev_loss != prev_l2dist)
          )
          fine_tuning[mask_fine_tune] = True
          self._reset_adam(self.adam_mean.size, np.repeat(mask_fine_tune, x_adv[0].size))  # type: ignore
          prev_l2dist = l2dist
  
          # Abort early if no improvement is obtained
          if self.abort_early and iter_ % self._early_stop_iters == 0:
              if (loss > 0.9999 * prev_loss).all():
                  break
              prev_loss = loss
  
          # Adjust the best result
          labels_batch = np.argmax(y_batch, axis=1)
          for i, (dist, pred) in enumerate(
              zip(l2dist, np.argmax(preds, axis=1))
          ):
              if dist < best_dist[i] and self._compare(
                  pred, labels_batch[i]
              ):
                  best_dist[i] = dist
                  best_attack[i] = x_adv[i]
                  best_label[i] = pred
  
      # Resize images to original size before returning
      best_attack = np.array(best_attack)
      if self.use_resize:
          if not self.estimator.channels_first:
              best_attack = zoom(
                  best_attack,
                  [
                      1,
                      int(x_batch.shape[1]) / best_attack.shape[1],
                      int(x_batch.shape[2]) / best_attack.shape[2],
                      1,
                  ],
              )
          else:
              best_attack = zoom(
                  best_attack,
                  [
                      1,
                      1,
                      int(x_batch.shape[2]) / best_attack.shape[2],
                      int(x_batch.shape[2]) / best_attack.shape[3],
                  ],
              )
  
      return best_dist, best_label, best_attack
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Optional, Tuple, Any, TYPE_CHECKING
  import numpy
  from scipy.ndimage import zoom
  from tqdm.auto import trange
  from art.config import ART_NUMPY_DTYPE
  from art.attacks.attack import EvasionAttack
  from art.estimators.estimator import BaseEstimator
  from art.estimators.classification.classifier import ClassifierMixin
  from art.utils import compute_success, get_labels_np_array, check_and_transform_label_format
label_desc: Use image node_id 7 for calling the ZooAttack obj's underlying member method code with example usage: obj._generate_bss(x_batch, y_batch, c_batch) and returns: best_dist,  best_label,  best_attack