class_docstr: Implementation of the adversarial patch attack for square and rectangular images and videos in PyTorch.
  
  | 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, nb_samples: int, sharpness: int = 40
  ) -> "torch.Tensor":
      """
      Return a circular patch mask.
      """
      import torch
  
      diameter = np.minimum(
          self.patch_shape[self.i_h_patch],
          self.patch_shape[self.i_w_patch],
      )
  
      if self.patch_type == "circle":
          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
          image_mask: Union[
              int, np.ndarray[Any, np.dtype[Any]]
          ] = 1 - np.clip(z_grid, -1, 1)
      elif self.patch_type == "square":
          image_mask = np.ones((diameter, diameter))
  
      image_mask = np.expand_dims(image_mask, axis=0)
      image_mask = np.broadcast_to(image_mask, self.patch_shape)
      image_mask_tensor = torch.Tensor(np.array(image_mask)).to(
          self.estimator.device
      )
      image_mask_tensor = torch.stack(
          [image_mask_tensor] * nb_samples, dim=0
      )
      return image_mask_tensor
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import math
  from typing import Any, Optional, Tuple, Union, TYPE_CHECKING
  import numpy
  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.utils import check_and_transform_label_format, is_probability, to_categorical
  from art.summary_writer import SummaryWriter
label_desc: Use image node_id 5 for calling the AdversarialPatchPyTorch obj's underlying member method code with example usage: obj._get_circular_patch_mask(nb_samples, sharpness) and returns: image_mask_tensor