class_docstr: Implementation of the adversarial texture attack on object trackers in PyTorch.
  
  | Paper link: https://arxiv.org/abs/1904.11042
class_docstr_tok: ["Implementation","of","the","adversarial","texture","attack","on","object","trackers","in","PyTorch",".","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1904.11042"]
docstr: A function to apply the learned adversarial texture to videos.
  
  :param x: Videos of shape NFHWC to apply adversarial texture.
  :param patch_external: External patch to apply to videos `x`.
  :param foreground: Foreground masks of shape NFHWC of boolean values with False/0.0 representing foreground,
                     preventing updates to the texture, and True/1.0 for background, allowing updates to the
                     texture.
  :param patch_points: Array of shape (nb_frames, 4, 2) containing four pairs of integers (height, width)
                       corresponding to the coordinates of the four corners top-left, top-right, bottom-right,
                       bottom-left of the transformed image in the coordinate-system of the original image.
  :return: The videos with adversarial textures.
docstr_tok: ["A","function","to","apply","the","learned","adversarial","texture","to","videos",".",":","param","x",":","Videos","of","shape","NFHWC","to","apply","adversarial","texture",".",":","param","patch_external",":","External","patch","to","apply","to","videos","`","x","`",".",":","param","foreground",":","Foreground","masks","of","shape","NFHWC","of","boolean","values","with","False\/0.0","representing","foreground",",","preventing","updates","to","the","texture",",","and","True\/1.0","for","background",",","allowing","updates","to","the","texture",".",":","param","patch_points",":","Array","of","shape","(","nb_frames",",","4",",","2",")","containing","four","pairs","of","integers","(","height",",","width",")","corresponding","to","the","coordinates","of","the","four","corners","top-left",",","top-right",",","bottom-right",",","bottom-left","of","the","transformed","image","in","the","coordinate-system","of","the","original","image",".",":","return",":","The","videos","with","adversarial","textures","."]
code: def apply_patch(
      self,
      x: np.ndarray,
      patch_external: Optional[np.ndarray] = None,
      foreground: Optional[np.ndarray] = None,
      patch_points: Optional[np.ndarray] = None,
  ) -> np.ndarray:
      """
      A function to apply the learned adversarial texture to videos.
  
      :param x: Videos of shape NFHWC to apply adversarial texture.
      :param patch_external: External patch to apply to videos `x`.
      :param foreground: Foreground masks of shape NFHWC of boolean values with False/0.0 representing foreground,
                         preventing updates to the texture, and True/1.0 for background, allowing updates to the
                         texture.
      :param patch_points: Array of shape (nb_frames, 4, 2) containing four pairs of integers (height, width)
                           corresponding to the coordinates of the four corners top-left, top-right, bottom-right,
                           bottom-left of the transformed image in the coordinate-system of the original image.
      :return: The videos with adversarial textures.
      """
      import torch
  
      patch_tensor = (
          torch.Tensor(patch_external).to(self.estimator.device)
          if patch_external is not None
          else self._patch
      )
      x_tensor = torch.Tensor(x).to(self.estimator.device)
      if foreground is None:
          foreground_tensor = None
      else:
          foreground_tensor = torch.Tensor(foreground).to(
              self.estimator.device
          )
  
      return (
          self._apply_texture(
              videos=x_tensor,
              patch=patch_tensor,
              foreground=foreground_tensor,
              patch_points=patch_points,
          )
          .detach()
          .cpu()
          .numpy()
      )
  
imports: import logging
  from typing import Dict, List, Optional, Union, TYPE_CHECKING
  import numpy
  from tqdm.auto import trange
  from art.attacks.attack import EvasionAttack
  from art.estimators.estimator import BaseEstimator, LossGradientsMixin
  from art.estimators.object_tracking.object_tracker import ObjectTrackerMixin
  from art.summary_writer import SummaryWriter
label_desc: Use image node_id 8 for calling the AdversarialTexturePyTorch obj's underlying member method code with example usage: obj.apply_patch(x, patch_external, foreground, patch_points) and returns: self