class_docstr: HopSkipJumpAttack was originally proposed by Chen, Jordan and Wainwright.
  It is a decision-based attack that requires access to output
  labels of a model alone.
  Paper link: https://arxiv.org/abs/1904.02144
  At a high level, this attack is an iterative attack composed of three
  steps: Binary search to approach the boundary; gradient estimation;
  stepsize search. HopSkipJumpAttack requires fewer model queries than
  Boundary Attack which was based on rejective sampling.
  :param model: cleverhans.model.Model
  :param sess: tf.Session
  :param dtypestr: dtype of the data
  :param kwargs: passed through to super constructor.
  see parse_params for details.
class_docstr_tok: ["HopSkipJumpAttack","was","originally","proposed","by","Chen",",","Jordan","and","Wainwright",".","It","is","a","decision-based","attack","that","requires","access","to","output","labels","of","a","model","alone",".","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1904.02144","At","a","high","level",",","this","attack","is","an","iterative","attack","composed","of","three","steps",":","Binary","search","to","approach","the","boundary",";","gradient","estimation",";","stepsize","search",".","HopSkipJumpAttack","requires","fewer","model","queries","than","Boundary","Attack","which","was","based","on","rejective","sampling",".",":","param","model",":","cleverhans.model.Model",":","param","sess",":","tf.Session",":","param","dtypestr",":","dtype","of","the","data",":","param","kwargs",":","passed","through","to","super","constructor",".","see","parse_params","for","details","."]
docstr: Return a tensor that constructs adversarial examples for the given
  input. Generate uses tf.py_func in order to operate over tensors.
  :param x: A tensor with the inputs.
  :param kwargs: See `parse_params`
docstr_tok: ["Return","a","tensor","that","constructs","adversarial","examples","for","the","given","input",".","Generate","uses","tf.py_func","in","order","to","operate","over","tensors",".",":","param","x",":","A","tensor","with","the","inputs",".",":","param","kwargs",":","See","`","parse_params","`"]
code: def generate(self, x, **kwargs):
      """
      Return a tensor that constructs adversarial examples for the given
      input. Generate uses tf.py_func in order to operate over tensors.
      :param x: A tensor with the inputs.
      :param kwargs: See `parse_params`
      """
      self.parse_params(**kwargs)
      shape = [int(i) for i in x.get_shape().as_list()[1:]]
  
      assert (
          self.sess is not None
      ), "Cannot use `generate` when no `sess` was provided"
      _check_first_dimension(x, "input")
      if self.y_target is not None:
          _check_first_dimension(self.y_target, "y_target")
          assert (
              self.image_target is not None
          ), "Require a target image for targeted attack."
          _check_first_dimension(self.image_target, "image_target")
  
      # Set shape and d.
      self.shape = shape
      self.d = int(np.prod(shape))
  
      # Set binary search threshold.
      if self.constraint == "l2":
          self.theta = self.gamma / (np.sqrt(self.d) * self.d)
      else:
          self.theta = self.gamma / (self.d * self.d)
  
      # Construct input placeholder and output for decision function.
      self.input_ph = tf.placeholder(
          tf_dtype, [None] + list(self.shape), name="input_image"
      )
      self.logits = self.model.get_logits(self.input_ph)
  
      def hsja_wrap(x, target_label, target_image):
          """Wrapper to use tensors as input and output."""
          return np.array(
              self._hsja(x, target_label, target_image),
              dtype=self.np_dtype,
          )
  
      if self.y_target is not None:
          # targeted attack that requires target label and image.
          wrap = tf.py_func(
              hsja_wrap,
              [x[0], self.y_target[0], self.image_target[0]],
              self.tf_dtype,
          )
      else:
          if self.image_target is not None:
              # untargeted attack with an initialized image.
              wrap = tf.py_func(
                  lambda x, target_image: hsja_wrap(
                      x, None, target_image
                  ),
                  [x[0], self.image_target[0]],
                  self.tf_dtype,
              )
          else:
              # untargeted attack without an initialized image.
              wrap = tf.py_func(
                  lambda x: hsja_wrap(x, None, None),
                  [x[0]],
                  self.tf_dtype,
              )
  
      wrap.set_shape(x.get_shape())
  
      return wrap
  
imports: import logging
  import numpy
  import tensorflow
  from warnings import warn
  from cleverhans.attacks import Attack
  from cleverhans.model import CallableModelWrapper, Model, wrapper_warning_logits
  from cleverhans import utils, utils_tf
label_desc: Use image node_id 2 for calling the HopSkipJumpAttack obj's underlying member method code with example usage: obj.generate(x) and returns: wrap, np