class_docstr: Implementation of the adversarial patch attack for square and rectangular images and videos in Numpy.
  
  | Paper link: https://arxiv.org/abs/1712.09665
class_docstr_tok: ["Implementation","of","the","adversarial","patch","attack","for","square","and","rectangular","images","and","videos","in","Numpy",".","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1712.09665"]
docstr: Augment images with randomly rotated, shifted and scaled patch.
docstr_tok: ["Augment","images","with","randomly","rotated",",","shifted","and","scaled","patch","."]
code: def _augment_images_with_random_patch(
      self, images, patch, mask=None, scale=None
  ):
      """
      Augment images with randomly rotated, shifted and scaled patch.
      """
      transformations = []
      patched_images = []
      patch_mask_transformed_list = []
  
      for i_image in range(images.shape[0]):
          if mask is not None:
              if mask.shape[0] == 1:
                  mask_2d = mask[0, :, :]
              else:
                  mask_2d = mask[i_image, :, :]
          else:
              mask_2d = mask
  
          (
              patch_transformed,
              patch_mask_transformed,
              transformation,
          ) = self._random_transformation(patch, scale, mask_2d)
  
          inverted_patch_mask_transformed = 1 - patch_mask_transformed
  
          patched_image = (
              images[i_image, :, :, :] * inverted_patch_mask_transformed
              + patch_transformed * patch_mask_transformed
          )
          patched_image = np.expand_dims(patched_image, axis=0)
          patched_images.append(patched_image)
  
          patch_mask_transformed = np.expand_dims(
              patch_mask_transformed, axis=0
          )
          patch_mask_transformed_list.append(patch_mask_transformed)
          transformations.append(transformation)
  
      patched_images = np.concatenate(patched_images, axis=0)
      patch_mask_transformed_np = np.concatenate(
          patch_mask_transformed_list, axis=0
      )
  
      return patched_images, patch_mask_transformed_np, transformations
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import math
  from typing import Optional, Union, Tuple, TYPE_CHECKING
  import random
  import numpy
  from scipy.ndimage import rotate, shift, zoom
  from tqdm.auto import trange
  from art.attacks.attack import EvasionAttack
  from art.attacks.evasion.adversarial_patch.utils import insert_transformed_patch
  from art.estimators.estimator import BaseEstimator, NeuralNetworkMixin
  from art.estimators.classification.classifier import ClassifierMixin
  from art.utils import check_and_transform_label_format
label_desc: Use image node_id 6 for calling the AdversarialPatchNumpy obj's underlying member method code with example usage: obj._augment_images_with_random_patch(images, patch, mask, scale) and returns: patched_images,  patch_mask_transformed_np,  transformations