class_docstr: The Projected Gradient Descent attack is an iterative method in which, after each iteration, the perturbation is
  projected on an lp-ball of specified radius (in addition to clipping the values of the adversarial sample so that it
  lies in the permitted data range). This is the attack proposed by Madry et al. for adversarial training.
  
  | Paper link: https://arxiv.org/abs/1706.06083
class_docstr_tok: ["The","Projected","Gradient","Descent","attack","is","an","iterative","method","in","which",",","after","each","iteration",",","the","perturbation","is","projected","on","an","lp-ball","of","specified","radius","(","in","addition","to","clipping","the","values","of","the","adversarial","sample","so","that","it","lies","in","the","permitted","data","range",")",".","This","is","the","attack","proposed","by","Madry","et","al",".","for","adversarial","training",".","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1706.06083"]
docstr: Generate a batch of adversarial samples and return them in an array.
  
  :param x: An array with the original inputs.
  :param targets: Target values (class labels) one-hot-encoded of shape `(nb_samples, nb_classes)`.
  :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 eps: Maximum perturbation that the attacker can introduce.
  :param eps_step: Attack step size (input variation) at each iteration.
  :return: Adversarial examples.
docstr_tok: ["Generate","a","batch","of","adversarial","samples","and","return","them","in","an","array",".",":","param","x",":","An","array","with","the","original","inputs",".",":","param","targets",":","Target","values","(","class","labels",")","one-hot-encoded","of","shape","`","(","nb_samples",",","nb_classes",")","`",".",":","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","eps",":","Maximum","perturbation","that","the","attacker","can","introduce",".",":","param","eps_step",":","Attack","step","size","(","input","variation",")","at","each","iteration",".",":","return",":","Adversarial","examples","."]
code: def _generate_batch(
      self,
      x: "tf.Tensor",
      targets: "tf.Tensor",
      mask: "tf.Tensor",
      eps: Union[int, float, np.ndarray],
      eps_step: Union[int, float, np.ndarray],
  ) -> "tf.Tensor":
      """
      Generate a batch of adversarial samples and return them in an array.
  
      :param x: An array with the original inputs.
      :param targets: Target values (class labels) one-hot-encoded of shape `(nb_samples, nb_classes)`.
      :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 eps: Maximum perturbation that the attacker can introduce.
      :param eps_step: Attack step size (input variation) at each iteration.
      :return: Adversarial examples.
      """
      import tensorflow as tf
  
      adv_x = tf.identity(x)
      momentum = tf.zeros(x.shape)
  
      for i_max_iter in range(self.max_iter):
          self._i_max_iter = i_max_iter
          adv_x = self._compute_tf(
              adv_x,
              x,
              targets,
              mask,
              eps,
              eps_step,
              momentum,
              self.num_random_init > 0 and i_max_iter == 0,
          )
  
      return adv_x
  
file_path: adversarial-robustness-toolbox/art/attacks/evasion/projected_gradient_descent/projected_gradient_descent_tensorflow_v2.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Optional, Union, TYPE_CHECKING
  import numpy
  from tqdm.auto import tqdm
  from art.config import ART_NUMPY_DTYPE
  from art.estimators.estimator import BaseEstimator, LossGradientsMixin
  from art.estimators.classification.classifier import ClassifierMixin
  from art.attacks.evasion.projected_gradient_descent.projected_gradient_descent_numpy import ProjectedGradientDescentCommon
  from art.utils import compute_success, random_sphere, compute_success_array
  from art.summary_writer import SummaryWriter
label_desc: Use image node_id 3 for calling the ProjectedGradientDescentTensorFlowV2 obj's underlying member method code with example usage: obj._generate_batch(x, targets, mask, eps, eps_step) and returns: adv_x