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: Return a circular patch mask
docstr_tok: ["Return","a","circular","patch","mask"]
code: def _get_circular_patch_mask(self, sharpness: int = 40) -> np.ndarray:
      """
      Return a circular patch mask
      """
      diameter = np.minimum(
          self.input_shape[self.i_h], self.input_shape[self.i_w]
      )
  
      x = np.linspace(-1, 1, diameter)
      y = np.linspace(-1, 1, diameter)
      x_grid, y_grid = np.meshgrid(x, y, sparse=True)
      z_grid = (x_grid**2 + y_grid**2) ** sharpness
  
      mask = 1 - np.clip(z_grid, -1, 1)
  
      channel_index = 1 if self.estimator.channels_first else 3
      axis = channel_index - 1
      mask = np.expand_dims(mask, axis=axis)
  
      mask = np.broadcast_to(mask, self.patch_shape).astype(np.float32)
  
      if self.nb_dims == 4:
          mask = np.expand_dims(mask, axis=0)
          mask = np.repeat(
              mask, axis=0, repeats=self.input_shape[0]
          ).astype(np.float32)
  
      return mask
  
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 5 for calling the AdversarialPatchNumpy obj's underlying member method code with example usage: obj._get_circular_patch_mask(sharpness) and returns: mask