class_docstr: Implements the Sign-OPT attack `SignOPTAttack`. This is a query-efficient
  hard-label adversarial attack.
  
  Paper link: https://arxiv.org/pdf/1909.10773.pdf
docstr: Generate adversarial samples and return them in an array.
  
  :param x: An array with the original inputs to be attacked.
  :param y: Target values (class labels) one-hot-encoded of
                  shape (nb_samples, nb_classes) or indices of shape
                  (nb_samples,). If `self.targeted` is true, then `y` represents the target labels.
  :param kwargs: See below.
  
  :Keyword Arguments:
      * *x_init* --
        Initialisation samples of the same shape as `x` for targeted attacks.
  
  :return: An array holding the adversarial examples.
docstr_tok: ["Generate","adversarial","samples","and","return","them","in","an","array",".",":","param","x",":","An","array","with","the","original","inputs","to","be","attacked",".",":","param","y",":","Target","values","(","class","labels",")","one-hot-encoded","of","shape","(","nb_samples",",","nb_classes",")","or","indices","of","shape","(","nb_samples",",",")",".","If","`","self.targeted","`","is","true",",","then","`","y","`","represents","the","target","labels",".",":","param","kwargs",":","See","below",".",":","Keyword","Arguments",":","*","*","x_init","*","--","Initialisation","samples","of","the","same","shape","as","`","x","`","for","targeted","attacks",".",":","return",":","An","array","holding","the","adversarial","examples","."]
code: def generate(
      self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs
  ) -> np.ndarray:
      """
      Generate adversarial samples and return them in an array.
  
      :param x: An array with the original inputs to be attacked.
      :param y: Target values (class labels) one-hot-encoded of
                      shape (nb_samples, nb_classes) or indices of shape
                      (nb_samples,). If `self.targeted` is true, then `y` represents the target labels.
      :param kwargs: See below.
  
      :Keyword Arguments:
          * *x_init* --
            Initialisation samples of the same shape as `x` for targeted attacks.
  
      :return: An array holding the adversarial examples.
      """
      if y is None:
          # Throw error if attack is targeted, but no targets are provided
          if self.targeted:  # pragma: no cover
              raise ValueError(
                  "Target labels `y` need to be provided for a targeted attack."
              )
  
          # Use model predictions as correct outputs
          y = get_labels_np_array(self.estimator.predict(x, batch_size=self.batch_size))  # type: ignore
  
      targets = check_and_transform_label_format(
          y, nb_classes=self.estimator.nb_classes, return_one_hot=False
      )
  
      if (
          targets is not None
          and self.estimator.nb_classes == 2
          and targets.shape[1] == 1
      ):
          raise ValueError(  # pragma: no cover
              "This attack has not yet been tested for binary classification with a single output classifier."
          )
  
      # Assert that if attack is targeted, targets is provided
      if self.targeted and targets is None:
          raise ValueError(
              "Target labels `y` need to be provided for a targeted attack."
          )
  
      x_init = kwargs.get("x_init")
  
      # Get clip_min and clip_max infer them from data, otherwise, it is initialized by self.estimator
      if self.clip_min is None and self.clip_max is None:
          self.clip_min, self.clip_max = np.min(x), np.max(x)
  
      # Prediction from the original images
      preds = np.argmax(
          self.estimator.predict(x, batch_size=self.batch_size), axis=1
      )
  
      # Some initial setups
      x_adv = x.astype(ART_NUMPY_DTYPE)
  
      # Generate the adversarial samples
      counter = 0  # only do the performance tests with 100 samples
      for ind, val in enumerate(
          tqdm(x_adv, desc="Sign_OPT attack", disable=not self.verbose)
      ):
          if self.targeted:
              if targets[ind] == preds[ind]:
                  if self.verbose:
                      print(
                          "Image already targeted. No need to attack."
                      )
                  continue
  
              if x_init is None:
                  raise ValueError(
                      "`x_init` needs to be provided for a targeted attack."
                  )
  
              (
                  x_adv[ind],
                  diff,
                  succeed,
              ) = self._attack(  # diff and succeed are for performance test
                  x_0=val,
                  y_0=preds[ind],
                  target=targets[ind],
                  x_init=x_init,
              )
          else:
              (
                  x_adv[ind],
                  diff,
                  succeed,
              ) = self._attack(  # diff and succeed are for performance test
                  x_0=val,
                  y_0=preds[ind],
              )
          if succeed and self.eval_perform and counter < 100:
              self.logs[counter] = np.linalg.norm(diff)
              counter += 1
  
      if self.targeted is False:
          logger.info(
              "Success rate of Sign_OPT attack: %.2f%%",
              100
              * compute_success(
                  self.estimator,
                  x,
                  targets,
                  x_adv,
                  self.targeted,
                  batch_size=self.batch_size,
              ),
          )
  
      return x_adv
  
imports: import logging
  from typing import Optional, TYPE_CHECKING, Tuple
  import time
  import numpy
  from tqdm.auto import tqdm
  from art.attacks.attack import EvasionAttack
  from art.config import ART_NUMPY_DTYPE
  from art.estimators.estimator import BaseEstimator
  from art.estimators.classification.classifier import ClassifierMixin
  from art.utils import compute_success, check_and_transform_label_format, get_labels_np_array
label_desc: Use image node_id 2 for calling the SignOPTAttack obj's underlying member method code with example usage: obj.generate(x, y) and returns: x_adv