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

        Augment images with randomly rotated, shifted and scaled patch.
        
art/attacks/evasion/adversarial_patch/adversarial_patch_numpy.py