class_docstr: Implementation of the adversarial patch attack for square and rectangular images and videos.
  
  | Paper link: https://arxiv.org/abs/1712.09665
class_docstr_tok: ["Implementation","of","the","adversarial","patch","attack","for","square","and","rectangular","images","and","videos",".","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1712.09665"]
docstr: Generate an adversarial patch and return the patch and its mask in arrays.
  
  :param x: An array with the original input images of shape NHWC or NCHW or input videos of shape NFHWC or NFCHW.
  :param y: An array with the original true labels.
  :param mask: A boolean array of shape equal to the shape of a single samples (1, H, W) or the shape of `x`
               (N, H, W) without their channel dimensions. Any features for which the mask is True can be the
               center location of the patch during sampling.
  :type mask: `np.ndarray`
  :param reset_patch: If `True` reset patch to initial values of mean of minimal and maximal clip value, else if
                      `False` (default) restart from previous patch values created by previous call to `generate`
                      or mean of minimal and maximal clip value if first call to `generate`.
  :type reset_patch: bool
  :return: An array with adversarial patch and an array of the patch mask.
docstr_tok: ["Generate","an","adversarial","patch","and","return","the","patch","and","its","mask","in","arrays",".",":","param","x",":","An","array","with","the","original","input","images","of","shape","NHWC","or","NCHW","or","input","videos","of","shape","NFHWC","or","NFCHW",".",":","param","y",":","An","array","with","the","original","true","labels",".",":","param","mask",":","A","boolean","array","of","shape","equal","to","the","shape","of","a","single","samples","(","1",",","H",",","W",")","or","the","shape","of","`","x","`","(","N",",","H",",","W",")","without","their","channel","dimensions",".","Any","features","for","which","the","mask","is","True","can","be","the","center","location","of","the","patch","during","sampling",".",":","type","mask",":","`","np.ndarray","`",":","param","reset_patch",":","If","`","True","`","reset","patch","to","initial","values","of","mean","of","minimal","and","maximal","clip","value",",","else","if","`","False","`","(","default",")","restart","from","previous","patch","values","created","by","previous","call","to","`","generate","`","or","mean","of","minimal","and","maximal","clip","value","if","first","call","to","`","generate","`",".",":","type","reset_patch",":","bool",":","return",":","An","array","with","adversarial","patch","and","an","array","of","the","patch","mask","."]
code: def generate(  # type: ignore
      self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs
  ) -> Tuple[np.ndarray, np.ndarray]:
      """
      Generate an adversarial patch and return the patch and its mask in arrays.
  
      :param x: An array with the original input images of shape NHWC or NCHW or input videos of shape NFHWC or NFCHW.
      :param y: An array with the original true labels.
      :param mask: A boolean array of shape equal to the shape of a single samples (1, H, W) or the shape of `x`
                   (N, H, W) without their channel dimensions. Any features for which the mask is True can be the
                   center location of the patch during sampling.
      :type mask: `np.ndarray`
      :param reset_patch: If `True` reset patch to initial values of mean of minimal and maximal clip value, else if
                          `False` (default) restart from previous patch values created by previous call to `generate`
                          or mean of minimal and maximal clip value if first call to `generate`.
      :type reset_patch: bool
      :return: An array with adversarial patch and an array of the patch mask.
      """
      logger.info("Creating adversarial patch.")
  
      if len(x.shape) == 2:  # pragma: no cover
          raise ValueError(
              "Feature vectors detected. The adversarial patch can only be applied to data with spatial "
              "dimensions."
          )
  
      return self._attack.generate(x=x, y=y, **kwargs)
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Optional, Tuple, Union, TYPE_CHECKING
  import numpy
  from art.attacks.evasion.adversarial_patch.adversarial_patch_numpy import AdversarialPatchNumpy
  from art.attacks.evasion.adversarial_patch.adversarial_patch_tensorflow import AdversarialPatchTensorFlowV2
  from art.attacks.evasion.adversarial_patch.adversarial_patch_pytorch import AdversarialPatchPyTorch
  from art.estimators.estimator import BaseEstimator, NeuralNetworkMixin
  from art.estimators.classification.classifier import ClassifierMixin
  from art.estimators.classification import TensorFlowV2Classifier, PyTorchClassifier
  from art.attacks.attack import EvasionAttack
label_desc: Use image node_id 2 for calling the AdversarialPatch obj's underlying member method code with example usage: obj.generate(x, y) and returns: self