class_docstr: Implementation of the white-box PyTorch GRAPHITE attack from Feng et al. (2022). This is a physical attack
  that generates robust physical perturbations that can be applied as stickers.
  
  | Paper link: https://arxiv.org/abs/2002.07088
  | Original github link: https://github.com/ryan-feng/GRAPHITE
class_docstr_tok: ["Implementation","of","the","white-box","PyTorch","GRAPHITE","attack","from","Feng","et","al",".","(","2022",")",".","This","is","a","physical","attack","that","generates","robust","physical","perturbations","that","can","be","applied","as","stickers",".","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/2002.07088","|","Original","github","link",":","https",":","\/\/github.com\/ryan-feng\/GRAPHITE"]
docstr: Create a GRAPHITEWhiteboxPyTorch attack instance.
  
  :param classifier: A trained classifier.
  :param net_size: The resolution to resize images to before feeding to the model in (w, h).
  :param min_tr: minimum threshold for EoT PGD to reach.
  :param num_xforms: The number of transforms to use.
  :param step_size: The step size.
  :param steps: The number of steps for EoT PGD after the first iteration.
  :param first_steps: The number of steps for EoT PGD for the first iteration.
  :param patch_removal_size: size of patch removal.
  :param patch_removal_interval: stride for patch removal.
  :param num_patches_to_remove: the number of patches to remove per iteration.
  :param rand_start_epsilon_range: the range for random start init.
  :param rotation_range: The range of the rotation in the perspective transform.
  :param dist_range: The range of the dist (in ft) to be added to the focal length in the perspective transform.
  :param gamma_range: The range of the gamma in the gamma transform.
  :param crop_percent_range: The range of the crop percent in the perspective transform.
  :param off_x_range: The range of the x offset (percent) in the perspective transform.
  :param off_y_range: The range of the y offset (percent) in the perspective transform.
  :param blur_kernels: The kernels to blur with.
  :param batch_size: The size of the batch used by the estimator during inference.
docstr_tok: ["Create","a","GRAPHITEWhiteboxPyTorch","attack","instance",".",":","param","classifier",":","A","trained","classifier",".",":","param","net_size",":","The","resolution","to","resize","images","to","before","feeding","to","the","model","in","(","w",",","h",")",".",":","param","min_tr",":","minimum","threshold","for","EoT","PGD","to","reach",".",":","param","num_xforms",":","The","number","of","transforms","to","use",".",":","param","step_size",":","The","step","size",".",":","param","steps",":","The","number","of","steps","for","EoT","PGD","after","the","first","iteration",".",":","param","first_steps",":","The","number","of","steps","for","EoT","PGD","for","the","first","iteration",".",":","param","patch_removal_size",":","size","of","patch","removal",".",":","param","patch_removal_interval",":","stride","for","patch","removal",".",":","param","num_patches_to_remove",":","the","number","of","patches","to","remove","per","iteration",".",":","param","rand_start_epsilon_range",":","the","range","for","random","start","init",".",":","param","rotation_range",":","The","range","of","the","rotation","in","the","perspective","transform",".",":","param","dist_range",":","The","range","of","the","dist","(","in","ft",")","to","be","added","to","the","focal","length","in","the","perspective","transform",".",":","param","gamma_range",":","The","range","of","the","gamma","in","the","gamma","transform",".",":","param","crop_percent_range",":","The","range","of","the","crop","percent","in","the","perspective","transform",".",":","param","off_x_range",":","The","range","of","the","x","offset","(","percent",")","in","the","perspective","transform",".",":","param","off_y_range",":","The","range","of","the","y","offset","(","percent",")","in","the","perspective","transform",".",":","param","blur_kernels",":","The","kernels","to","blur","with",".",":","param","batch_size",":","The","size","of","the","batch","used","by","the","estimator","during","inference","."]
code: def __init__(
      self,
      classifier: "PyTorchClassifier",
      net_size: Tuple[int, int],
      min_tr: float = 0.8,
      num_xforms: int = 100,
      step_size: float = 0.0157,
      steps: int = 50,
      first_steps: int = 500,
      patch_removal_size: float = 4,
      patch_removal_interval: float = 2,
      num_patches_to_remove: int = 4,
      rand_start_epsilon_range: Tuple[float, float] = (
          -8 / 255,
          8 / 255,
      ),
      rotation_range: Tuple[float, float] = (-30.0, 30.0),
      dist_range: Tuple[float, float] = (0.0, 0.0),
      gamma_range: Tuple[float, float] = (1.0, 2.0),
      crop_percent_range: Tuple[float, float] = (-0.03125, 0.03125),
      off_x_range: Tuple[float, float] = (-0.03125, 0.03125),
      off_y_range: Tuple[float, float] = (-0.03125, 0.03125),
      blur_kernels: Union[Tuple[int, int], List[int]] = (0, 3),
      batch_size: int = 64,
  ) -> None:
      """
      Create a GRAPHITEWhiteboxPyTorch attack instance.
  
      :param classifier: A trained classifier.
      :param net_size: The resolution to resize images to before feeding to the model in (w, h).
      :param min_tr: minimum threshold for EoT PGD to reach.
      :param num_xforms: The number of transforms to use.
      :param step_size: The step size.
      :param steps: The number of steps for EoT PGD after the first iteration.
      :param first_steps: The number of steps for EoT PGD for the first iteration.
      :param patch_removal_size: size of patch removal.
      :param patch_removal_interval: stride for patch removal.
      :param num_patches_to_remove: the number of patches to remove per iteration.
      :param rand_start_epsilon_range: the range for random start init.
      :param rotation_range: The range of the rotation in the perspective transform.
      :param dist_range: The range of the dist (in ft) to be added to the focal length in the perspective transform.
      :param gamma_range: The range of the gamma in the gamma transform.
      :param crop_percent_range: The range of the crop percent in the perspective transform.
      :param off_x_range: The range of the x offset (percent) in the perspective transform.
      :param off_y_range: The range of the y offset (percent) in the perspective transform.
      :param blur_kernels: The kernels to blur with.
      :param batch_size: The size of the batch used by the estimator during inference.
      """
      super().__init__(estimator=classifier)
      self.net_size = net_size
      self.min_tr = min_tr
      self.num_xforms = num_xforms
      self.step_size = step_size
      self.steps = steps
      self.first_steps = first_steps
      self.patch_removal_size = patch_removal_size
      self.patch_removal_interval = patch_removal_interval
      self.num_patches_to_remove = num_patches_to_remove
      self.rand_start_epsilon_range = rand_start_epsilon_range
      self.rotation_range = rotation_range
      self.dist_range = dist_range
      self.gamma_range = gamma_range
      self.crop_percent_range = crop_percent_range
      self.off_x_range = off_x_range
      self.off_y_range = off_y_range
      self.blur_kernels = blur_kernels
      self.batch_size = batch_size
  
      self._check_params()
  
file_path: adversarial-robustness-toolbox/art/attacks/evasion/graphite/graphite_whitebox_pytorch.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Optional, Tuple, Union, TYPE_CHECKING, List
  import numpy
  from art.config import ART_NUMPY_DTYPE
  from art.attacks.attack import EvasionAttack
  from art.estimators.estimator import BaseEstimator
  from art.estimators.classification import ClassifierMixin
  from art.utils import compute_success, to_categorical, check_and_transform_label_format, is_probability
  from art.attacks.evasion.graphite.utils import convert_to_network, get_transform_params, transform_wb
label_desc: Use image node_id 1 to create a new GRAPHITEWhiteboxPyTorch object from inherited base classes: EvasionAttack with example: obj = GRAPHITEWhiteboxPyTorch(classifier, net_size, min_tr, num_xforms, step_size, steps, first_steps, patch_removal_size, patch_removal_interval, num_patches_to_remove, rand_start_epsilon_range, rotation_range, dist_range, gamma_range, crop_percent_range, off_x_range, off_y_range, blur_kernels, batch_size)