class_docstr: Implementation of the HopSkipJump attack from Jianbo et al. (2019). This is a powerful black-box attack that
  only requires final class prediction, and is an advanced version of the boundary attack.
  
  | Paper link: https://arxiv.org/abs/1904.02144
docstr: Find initial adversarial example for the attack.
  
  :param x: An array with 1 original input to be attacked.
  :param y: If `self.targeted` is true, then `y` represents the target label.
  :param y_p: The predicted label of x.
  :param init_pred: The predicted label of the initial image.
  :param adv_init: Initial array to act as an initial adversarial example.
  :param mask: An array with a mask to be applied to the adversarial perturbations. Shape needs to be
               broadcastable to the shape of x. Any features for which the mask is zero will not be adversarially
               perturbed.
  :param clip_min: Minimum value of an example.
  :param clip_max: Maximum value of an example.
  :return: An adversarial example.
docstr_tok: ["Find","initial","adversarial","example","for","the","attack",".",":","param","x",":","An","array","with","1","original","input","to","be","attacked",".",":","param","y",":","If","`","self.targeted","`","is","true",",","then","`","y","`","represents","the","target","label",".",":","param","y_p",":","The","predicted","label","of","x.",":","param","init_pred",":","The","predicted","label","of","the","initial","image",".",":","param","adv_init",":","Initial","array","to","act","as","an","initial","adversarial","example",".",":","param","mask",":","An","array","with","a","mask","to","be","applied","to","the","adversarial","perturbations",".","Shape","needs","to","be","broadcastable","to","the","shape","of","x",".","Any","features","for","which","the","mask","is","zero","will","not","be","adversarially","perturbed",".",":","param","clip_min",":","Minimum","value","of","an","example",".",":","param","clip_max",":","Maximum","value","of","an","example",".",":","return",":","An","adversarial","example","."]
code: def _init_sample(
      self,
      x: np.ndarray,
      y: int,
      y_p: int,
      init_pred: int,
      adv_init: np.ndarray,
      mask: Optional[np.ndarray],
      clip_min: float,
      clip_max: float,
  ) -> Optional[Union[np.ndarray, Tuple[np.ndarray, int]]]:
      """
      Find initial adversarial example for the attack.
  
      :param x: An array with 1 original input to be attacked.
      :param y: If `self.targeted` is true, then `y` represents the target label.
      :param y_p: The predicted label of x.
      :param init_pred: The predicted label of the initial image.
      :param adv_init: Initial array to act as an initial adversarial example.
      :param mask: An array with a mask to be applied to the adversarial perturbations. Shape needs to be
                   broadcastable to the shape of x. Any features for which the mask is zero will not be adversarially
                   perturbed.
      :param clip_min: Minimum value of an example.
      :param clip_max: Maximum value of an example.
      :return: An adversarial example.
      """
      nprd = np.random.RandomState()
      initial_sample = None
  
      if self.targeted:
          # Attack satisfied
          if y == y_p:
              return None
  
          # Attack unsatisfied yet and the initial image satisfied
          if adv_init is not None and init_pred == y:
              return adv_init.astype(ART_NUMPY_DTYPE), init_pred
  
          # Attack unsatisfied yet and the initial image unsatisfied
          for _ in range(self.init_size):
              random_img = nprd.uniform(
                  clip_min, clip_max, size=x.shape
              ).astype(x.dtype)
  
              if mask is not None:
                  random_img = random_img * mask + x * (1 - mask)
  
              random_class = np.argmax(
                  self.estimator.predict(
                      np.array([random_img]), batch_size=self.batch_size
                  ),
                  axis=1,
              )[0]
  
              if random_class == y:
                  # Binary search to reduce the l2 distance to the original image
                  random_img = self._binary_search(
                      current_sample=random_img,
                      original_sample=x,
                      target=y,
                      norm=2,
                      clip_min=clip_min,
                      clip_max=clip_max,
                      threshold=0.001,
                  )
                  initial_sample = random_img, random_class
  
                  logger.info(
                      "Found initial adversarial image for targeted attack."
                  )
                  break
          else:
              logger.warning(
                  "Failed to draw a random image that is adversarial, attack failed."
              )
  
      else:
          # The initial image satisfied
          if adv_init is not None and init_pred != y_p:
              return adv_init.astype(ART_NUMPY_DTYPE), y_p
  
          # The initial image unsatisfied
          for _ in range(self.init_size):
              random_img = nprd.uniform(
                  clip_min, clip_max, size=x.shape
              ).astype(x.dtype)
  
              if mask is not None:
                  random_img = random_img * mask + x * (1 - mask)
  
              random_class = np.argmax(
                  self.estimator.predict(
                      np.array([random_img]), batch_size=self.batch_size
                  ),
                  axis=1,
              )[0]
  
              if random_class != y_p:
                  # Binary search to reduce the l2 distance to the original image
                  random_img = self._binary_search(
                      current_sample=random_img,
                      original_sample=x,
                      target=y_p,
                      norm=2,
                      clip_min=clip_min,
                      clip_max=clip_max,
                      threshold=0.001,
                  )
                  initial_sample = random_img, y_p
  
                  logger.info(
                      "Found initial adversarial image for untargeted attack."
                  )
                  break
          else:
              logger.warning(
                  "Failed to draw a random image that is adversarial, attack failed."
              )
  
      return initial_sample
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Optional, Tuple, Union, TYPE_CHECKING
  import numpy
  from tqdm.auto import tqdm
  from art.config import ART_NUMPY_DTYPE
  from art.attacks.attack import EvasionAttack
  from art.estimators.estimator import BaseEstimator
  from art.estimators.classification import ClassifierMixin
  from art.utils import compute_success, to_categorical, check_and_transform_label_format, get_labels_np_array
label_desc: Use image node_id 4 for calling the HopSkipJump obj's underlying member method code with example usage: obj._init_sample(x, y, y_p, init_pred, adv_init, mask, clip_min, clip_max) and returns: initial_sample, None, adv_init,  init_pred, adv_init,  y_p