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: Create an instance of the :class:`.AdversarialTexturePyTorch`.
  
  :param estimator: A trained estimator.
  :param patch_height: Height of patch.
  :param patch_width: Width of patch.
  :param x_min: Vertical position of patch, top-left corner.
  :param y_min: Horizontal position of patch, top-left corner.
  :param step_size: The step size.
  :param max_iter: The number of optimization steps.
  :param batch_size: The size of the training batch.
  :param summary_writer: Activate summary writer for TensorBoard.
                         Default is `False` and deactivated summary writer.
                         If `True` save runs/CURRENT_DATETIME_HOSTNAME in current directory.
                         If of type `str` save in path.
                         If of type `SummaryWriter` apply provided custom summary writer.
                         Use hierarchical folder structure to compare between runs easily. e.g. pass in
                         ‘runs/exp1’, ‘runs/exp2’, etc. for each new experiment to compare across them.
  :param verbose: Show progress bars.
docstr_tok: ["Create","an","instance","of","the",":","class",":","`",".AdversarialTexturePyTorch","`",".",":","param","estimator",":","A","trained","estimator",".",":","param","patch_height",":","Height","of","patch",".",":","param","patch_width",":","Width","of","patch",".",":","param","x_min",":","Vertical","position","of","patch",",","top-left","corner",".",":","param","y_min",":","Horizontal","position","of","patch",",","top-left","corner",".",":","param","step_size",":","The","step","size",".",":","param","max_iter",":","The","number","of","optimization","steps",".",":","param","batch_size",":","The","size","of","the","training","batch",".",":","param","summary_writer",":","Activate","summary","writer","for","TensorBoard",".","Default","is","`","False","`","and","deactivated","summary","writer",".","If","`","True","`","save","runs\/CURRENT_DATETIME_HOSTNAME","in","current","directory",".","If","of","type","`","str","`","save","in","path",".","If","of","type","`","SummaryWriter","`","apply","provided","custom","summary","writer",".","Use","hierarchical","folder","structure","to","compare","between","runs","easily",".","e.g",".","pass","in","\u2018","runs\/exp1","\u2019",",","\u2018","runs\/exp2","\u2019",",","etc",".","for","each","new","experiment","to","compare","across","them",".",":","param","verbose",":","Show","progress","bars","."]
code: def __init__(
      self,
      estimator,
      patch_height: int,
      patch_width: int,
      x_min: int = 0,
      y_min: int = 0,
      step_size: float = 1.0 / 255.0,
      max_iter: int = 500,
      batch_size: int = 16,
      summary_writer: Union[str, bool, SummaryWriter] = False,
      verbose: bool = True,
  ):
      """
      Create an instance of the :class:`.AdversarialTexturePyTorch`.
  
      :param estimator: A trained estimator.
      :param patch_height: Height of patch.
      :param patch_width: Width of patch.
      :param x_min: Vertical position of patch, top-left corner.
      :param y_min: Horizontal position of patch, top-left corner.
      :param step_size: The step size.
      :param max_iter: The number of optimization steps.
      :param batch_size: The size of the training batch.
      :param summary_writer: Activate summary writer for TensorBoard.
                             Default is `False` and deactivated summary writer.
                             If `True` save runs/CURRENT_DATETIME_HOSTNAME in current directory.
                             If of type `str` save in path.
                             If of type `SummaryWriter` apply provided custom summary writer.
                             Use hierarchical folder structure to compare between runs easily. e.g. pass in
                             ‘runs/exp1’, ‘runs/exp2’, etc. for each new experiment to compare across them.
      :param verbose: Show progress bars.
      """
      import torch
  
      super().__init__(
          estimator=estimator, summary_writer=summary_writer
      )
      self.patch_height = patch_height
      self.patch_width = patch_width
      self.x_min = x_min
      self.y_min = y_min
      self.step_size = step_size
      self.max_iter = max_iter
      self.batch_size = batch_size
      self.verbose = verbose
      self._check_params()
  
      self._batch_id = 0
      self._i_max_iter = 0
  
      self.patch_shape = (self.patch_height, self.patch_width, 3)
  
      if self.estimator.channels_first:
          raise ValueError(
              "Input shape has to be either NHWC or NFHWC."
          )
  
      self.i_h_patch = 0
      self.i_w_patch = 1
  
      self.i_h = 1
      self.i_w = 2
  
      if not (
          self.estimator.postprocessing_defences is None
          or self.estimator.postprocessing_defences == []
      ):
          raise ValueError(
              "Framework-specific implementation of Adversarial Patch attack does not yet support "
              + "postprocessing defences."
          )
  
      mean_value = (
          self.estimator.clip_values[1] - self.estimator.clip_values[0]
      ) / 2.0 + self.estimator.clip_values[0]
      self._initial_value = np.ones(self.patch_shape) * mean_value
      self._patch = torch.tensor(
          self._initial_value,
          requires_grad=True,
          device=self.estimator.device,
      )
  
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 1 to create a new AdversarialTexturePyTorch object from inherited base classes: EvasionAttack with example: obj = AdversarialTexturePyTorch(estimator, patch_height, patch_width, x_min, y_min, step_size, max_iter, batch_size, summary_writer, verbose)