class_docstr: Implementation of the adversarial patch attack for square and rectangular images and videos in TensorFlow v2.
  
  | Paper link: https://arxiv.org/abs/1712.09665
code: def _check_mask(
      self, mask: Optional[np.ndarray], x: np.ndarray
  ) -> Optional[np.ndarray]:
      if mask is not None and (  # pragma: no cover
          (mask.dtype != bool)
          or not (mask.shape[0] == 1 or mask.shape[0] == x.shape[0])
          or not (
              mask.shape[1] == x.shape[self.i_h + 1]
              and mask.shape[2] == x.shape[self.i_w + 1]
          )
      ):
          raise ValueError(
              "The shape of `mask` has to be equal to the shape of a single samples (1, H, W) or the"
              "shape of `x` (N, H, W) without their channel dimensions."
          )
  
      if mask is not None and mask.shape[0] == 1:
          mask = np.repeat(mask, repeats=x.shape[0], axis=0)
  
      return mask
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import math
  from typing import 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.estimators.classification.classifier import ClassifierMixin
  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 8 for calling the AdversarialPatchTensorFlowV2 obj's underlying member method code with example usage: obj._check_mask(mask, x) and returns: mask