docstr: Perform the EAD attack on the given instance for the given targets.
  
  If self.targeted is true, then the targets represents the target labels
  If self.targeted is false, then targets are the original class labels
docstr_tok: ["Perform","the","EAD","attack","on","the","given","instance","for","the","given","targets",".","If","self.targeted","is","true",",","then","the","targets","represents","the","target","labels","If","self.targeted","is","false",",","then","targets","are","the","original","class","labels"]
code: def attack(self, imgs, targets):
      """
      Perform the EAD attack on the given instance for the given targets.
  
      If self.targeted is true, then the targets represents the target labels
      If self.targeted is false, then targets are the original class labels
      """
  
      batch_size = self.batch_size
      r = []
      for i in range(0, len(imgs) // batch_size):
          _logger.debug(
              (
                  "Running EAD attack on instance %s of %s",
                  i * batch_size,
                  len(imgs),
              )
          )
          r.extend(
              self.attack_batch(
                  imgs[i * batch_size : (i + 1) * batch_size],
                  targets[i * batch_size : (i + 1) * batch_size],
              )
          )
      if len(imgs) % batch_size != 0:
          last_elements = len(imgs) - (len(imgs) % batch_size)
          _logger.debug(
              (
                  "Running EAD attack on instance %s of %s",
                  last_elements,
                  len(imgs),
              )
          )
          temp_imgs = np.zeros((batch_size,) + imgs.shape[2:])
          temp_targets = np.zeros((batch_size,) + targets.shape[2:])
          temp_imgs[: (len(imgs) % batch_size)] = imgs[last_elements:]
          temp_targets[: (len(imgs) % batch_size)] = targets[
              last_elements:
          ]
          temp_data = self.attack_batch(temp_imgs, temp_targets)
          r.extend(
              temp_data[: (len(imgs) % batch_size)],
              targets[last_elements:],
          )
      return np.array(r)
  
file_path: cleverhans/cleverhans_v3.1.0/cleverhans/attacks/elastic_net_method.py
imports: import logging
  import numpy
  import tensorflow
  from cleverhans.attacks.attack import Attack
  from cleverhans.compat import reduce_sum, reduce_max
  from cleverhans.model import Model, CallableModelWrapper, wrapper_warning_logits
  from cleverhans import utils
label_desc: Use image node_id 2 for calling the EAD obj's underlying member method code with example usage: obj.attack(imgs, targets) and returns: np