class_docstr: These attacks were originally implemented by Vargas et al. (2019) & Su et al.(2019).
  
  | One Pixel Attack Paper link: https://arxiv.org/abs/1710.08864
  | Pixel and Threshold Attack Paper link: https://arxiv.org/abs/1906.06026
docstr: Attack the given image `image` with the threshold `limit` for the `target_class` which is true label for
  untargeted attack and targeted label for targeted attack.
docstr_tok: ["Attack","the","given","image","`","image","`","with","the","threshold","`","limit","`","for","the","`","target_class","`","which","is","true","label","for","untargeted","attack","and","targeted","label","for","targeted","attack","."]
code: def _attack(
      self, image: np.ndarray, target_class: np.ndarray, limit: int
  ) -> Tuple[bool, np.ndarray]:
      """
      Attack the given image `image` with the threshold `limit` for the `target_class` which is true label for
      untargeted attack and targeted label for targeted attack.
      """
      bounds, initial = self._get_bounds(image, limit)
  
      def predict_fn(x):
          adv = self._perturb_image(x, image)
  
          if self.rescale:
              adv = self.rescale_input(adv)
  
          predictions = self.estimator.predict(adv)[:, target_class]
          return predictions if not self.targeted else 1 - predictions
  
      def callback_fn(
          x, convergence=None
      ):  # pylint: disable=R1710,W0613
          if self.es == 0:
              if self._attack_success(x.result[0], image, target_class):
                  raise CMAEarlyStoppingException(
                      "Attack Completed :) Earlier than expected"
                  )
          else:
              return self._attack_success(x, image, target_class)
  
      if self.es == 0:
          from cma import CMAOptions
  
          opts = CMAOptions()
          if not self.verbose_es:
              opts.set("verbose", -9)
              opts.set("verb_disp", 40000)
              opts.set("verb_log", 40000)
              opts.set("verb_time", False)
  
          opts.set("bounds", bounds)
  
          if self.type_attack == 0:
              std = 63
          else:  # pragma: no cover
              std = limit
  
          from cma import CMAEvolutionStrategy
  
          strategy = CMAEvolutionStrategy(initial, std / 4, opts)
  
          try:
              strategy.optimize(
                  predict_fn,
                  maxfun=max(1, 400 // len(bounds)) * len(bounds) * 100,
                  callback=callback_fn,
                  iterations=self.max_iter,
              )
          except CMAEarlyStoppingException as err:
              if self.verbose_es:  # pragma: no cover
                  logger.info(err)
  
          adv_x = strategy.result[0]
      else:
          strategy = differential_evolution(
              predict_fn,
              bounds,
              disp=self.verbose_es,
              maxiter=self.max_iter,
              popsize=max(1, 400 // len(bounds)),
              recombination=1,
              atol=-1,
              callback=callback_fn,
              polish=False,
          )
          adv_x = strategy.x
  
      if self._attack_success(adv_x, image, target_class):
          return True, self._perturb_image(adv_x, image)[0]
  
      return False, image
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from itertools import product
  from typing import List, Optional, Tuple, TYPE_CHECKING
  import numpy
  from six import string_types
  import scipy
  from scipy._lib._util import check_random_state
  from scipy.optimize import OptimizeResult, minimize
  from tqdm.auto import tqdm
  from art.config import ART_NUMPY_DTYPE
  from art.attacks.attack import EvasionAttack
  from art.estimators.estimator import BaseEstimator, NeuralNetworkMixin
  from art.estimators.classification.classifier import ClassifierMixin
  from art.utils import check_and_transform_label_format
label_desc: Use image node_id 8 for calling the PixelThreshold obj's underlying member method code with example usage: obj._attack(image, target_class, limit) and returns: False,  image, unknown, True,  self, self