class_docstr: This module contains an implementation of the Over-the-Air Adversarial Flickering attack on video recognition
  networks.
  
  | Paper link: https://arxiv.org/abs/2002.05123
class_docstr_tok: ["This","module","contains","an","implementation","of","the","Over-the-Air","Adversarial","Flickering","attack","on","video","recognition","networks",".","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/2002.05123"]
docstr: Generate adversarial examples.
  
  :param x: Original input samples representing videos of format NFHWC.
  :param y: Target values (class labels) one-hot-encoded of shape (nb_samples, nb_classes) or indices of shape
            (nb_samples,).
  :return: Adversarial examples.
docstr_tok: ["Generate","adversarial","examples",".",":","param","x",":","Original","input","samples","representing","videos","of","format","NFHWC",".",":","param","y",":","Target","values","(","class","labels",")","one-hot-encoded","of","shape","(","nb_samples",",","nb_classes",")","or","indices","of","shape","(","nb_samples",",",")",".",":","return",":","Adversarial","examples","."]
code: def generate(
      self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs
  ) -> np.ndarray:
      """
      Generate adversarial examples.
  
      :param x: Original input samples representing videos of format NFHWC.
      :param y: Target values (class labels) one-hot-encoded of shape (nb_samples, nb_classes) or indices of shape
                (nb_samples,).
      :return: Adversarial examples.
      """
      import torch
  
      if y is not None:
          y = check_and_transform_label_format(
              y, nb_classes=self.estimator.nb_classes
          )
      if y is None:
          if self.targeted:  # pragma: no cover
              raise ValueError(
                  "Target labels `y` need to be provided for a targeted attack."
              )
  
          # Use model predictions as true labels
          logger.info("Using model predictions as true labels.")
          y = get_labels_np_array(
              self.estimator.predict(x, batch_size=self.batch_size)
          )
  
      dataset = torch.utils.data.TensorDataset(
          torch.from_numpy(x.astype(ART_NUMPY_DTYPE)),
          torch.from_numpy(y.astype(ART_NUMPY_DTYPE)),
      )
  
      data_loader = torch.utils.data.DataLoader(
          dataset=dataset,
          batch_size=self.batch_size,
          shuffle=False,
          drop_last=False,
      )
  
      x_adv = x.copy().astype(ART_NUMPY_DTYPE)
  
      # Compute perturbation with batching
      for batch_id, batch_all in enumerate(
          tqdm(
              data_loader,
              desc="OverTheAirFlickeringPyTorch - Batches",
              leave=False,
              disable=not self.verbose,
          )
      ):
          (batch, batch_labels) = batch_all[0], batch_all[1]
  
          batch_index_1, batch_index_2 = (
              batch_id * self.batch_size,
              (batch_id + 1) * self.batch_size,
          )
          x_adv[batch_index_1:batch_index_2] = self._generate_batch(
              batch, batch_labels
          )
  
      return x_adv
  
imports: import logging
  from typing import Optional, TYPE_CHECKING
  import numpy
  from tqdm.auto import tqdm
  from art.config import ART_NUMPY_DTYPE
  from art.estimators.estimator import BaseEstimator
  from art.estimators.classification.classifier import ClassifierMixin, LossGradientsMixin
  from art.attacks.attack import EvasionAttack
  from art.utils import check_and_transform_label_format, get_labels_np_array
label_desc: Use image node_id 2 for calling the OverTheAirFlickeringPyTorch obj's underlying member method code with example usage: obj.generate(x, y) and returns: x_adv