original_docstring: 
      Generate adversarial samples and return them in an array.
  
      :param x: An array with the original inputs.
      :type x: `np.ndarray`
      :param y: Target values
                Default is `None`.
      :type y: `np.ndarray`
      :return: An array holding the adversarial examples.
      :rtype: `np.ndarray`
      
docstring: Generate adversarial samples and return them in an array.
docstring_tokens: Generate adversarial samples and return them in an array .
code: def generate(self, x, y=None, **kwargs):
      """
      Generate adversarial samples and return them in an array.
  
      :param x: An array with the original inputs.
      :type x: `np.ndarray`
      :param y: Target values
                Default is `None`.
      :type y: `np.ndarray`
      :return: An array holding the adversarial examples.
      :rtype: `np.ndarray`
      """
      if y is None:
        if self.targeted:
          raise ValueError(
              'Target labels `y` need to be provided for a targeted '
              'attack.'
          )
        y = np.argmax(self.classifier.predict(x), axis=1)
  
      if np.amax(x) > 1:
        self.bound_limit = 255
      else:
        self.bound_limit = 1
  
      adv_x_best = []
      for image, target_class in zip(x, y):
        if self.th is None:
          self.min_th = 127
          start, end = 1, 127
          while True:
            image_result = []
            threshold = (start + end) // 2
            success, trial_image_result = self.attack(
                image, target_class, threshold)
            if image_result or success:
              image_result = trial_image_result
            if success:
              end = threshold - 1
            else:
              start = threshold + 1
            if success:
              self.min_th = threshold
            if end < start:
              break
        else:
          success, image_result = self.attack(x, y, self.th)
        adv_x_best += [image_result]
  
      adv_x_best = np.array(adv_x_best)
      return adv_x_best
code_tokens: def generate ( self , x , y = None , ** kwargs ) : if y is None : if self . targeted : raise ValueError ( 'Target labels `y` need to be provided for a targeted ' 'attack.' ) y = np . argmax ( self . classifier . predict ( x ) , axis = 1 ) if np . amax ( x ) > 1 : self . bound_limit = 255 else : self . bound_limit = 1 adv_x_best = [ ] for image , target_class in zip ( x , y ) : if self . th is None : self . min_th = 127 start , end = 1 , 127 while True : image_result = [ ] threshold = ( start + end ) // 2 success , trial_image_result = self . attack ( image , target_class , threshold ) if image_result or success : image_result = trial_image_result if success : end = threshold - 1 else : start = threshold + 1 if success : self . min_th = threshold if end < start : break else : success , image_result = self . attack ( x , y , self . th ) adv_x_best += [ image_result ] adv_x_best = np . array ( adv_x_best ) return adv_x_best
short_docstring: Generate adversarial samples and return them in an array.
short_docstring_tokens: Generate adversarial samples and return them in an array .
comment: """
      Generate adversarial samples and return them in an array.
  
      :param x: An array with the original inputs.
      :type x: `np.ndarray`
      :param y: Target values
                Default is `None`.
      :type y: `np.ndarray`
      :return: An array holding the adversarial examples.
      :rtype: `np.ndarray`
      """