class_docstr: Implementation of the hard-label GRAPHITE attack from Feng et al. (2022). This is a physical, black-box attack
  that only requires final class prediction and 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 GRAPHITEBlackbox attack instance.
  
  :param classifier: A trained classifier.
  :param noise_size: The resolution to generate perturbations in (w, h).
  :param net_size: The resolution to resize images to before feeding to the model in (w, h).
  :param heat_patch_size: The size of the heatmap patches in (w, h).
  :param heat_patch_stride: The stride of the heatmap patching in (w, h).
  :param heatmap_mode: The mode of heatmap in ['Target', 'Random'].
  :param tr_lo: tr_lo, threshold for fine-grained reduction.
  :param tr_hi: tr_hi, threshold for coarse-grained reduction.
  :param num_xforms_mask: The number of transforms to use in mask generation.
  :param max_mask_size: Optionally specify that you just want to optimize until a mask size of <= max_mask_size.
  :param beta: The parameter beta for RGF optimization in boosting.
  :param eta: The step size for RGF optimization in boosting.
  :param num_xforms_boost: The number of transforms to use in boosting.
  :param num_boost_queries: The number of queries to use in boosting.
  :param rotation_range: The range of the rotation in the perspective transform.
  :param dist_range: The range of the distance (in ft) to be added to the focal length in 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","GRAPHITEBlackbox","attack","instance",".",":","param","classifier",":","A","trained","classifier",".",":","param","noise_size",":","The","resolution","to","generate","perturbations","in","(","w",",","h",")",".",":","param","net_size",":","The","resolution","to","resize","images","to","before","feeding","to","the","model","in","(","w",",","h",")",".",":","param","heat_patch_size",":","The","size","of","the","heatmap","patches","in","(","w",",","h",")",".",":","param","heat_patch_stride",":","The","stride","of","the","heatmap","patching","in","(","w",",","h",")",".",":","param","heatmap_mode",":","The","mode","of","heatmap","in","[","'Target","'",",","'Random","'","]",".",":","param","tr_lo",":","tr_lo",",","threshold","for","fine-grained","reduction",".",":","param","tr_hi",":","tr_hi",",","threshold","for","coarse-grained","reduction",".",":","param","num_xforms_mask",":","The","number","of","transforms","to","use","in","mask","generation",".",":","param","max_mask_size",":","Optionally","specify","that","you","just","want","to","optimize","until","a","mask","size","of","<","=","max_mask_size",".",":","param","beta",":","The","parameter","beta","for","RGF","optimization","in","boosting",".",":","param","eta",":","The","step","size","for","RGF","optimization","in","boosting",".",":","param","num_xforms_boost",":","The","number","of","transforms","to","use","in","boosting",".",":","param","num_boost_queries",":","The","number","of","queries","to","use","in","boosting",".",":","param","rotation_range",":","The","range","of","the","rotation","in","the","perspective","transform",".",":","param","dist_range",":","The","range","of","the","distance","(","in","ft",")","to","be","added","to","the","focal","length","in","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: "CLASSIFIER_NEURALNETWORK_TYPE",
      noise_size: Tuple[int, int],
      net_size: Tuple[int, int],
      heat_patch_size: Tuple[int, int] = (4, 4),
      heat_patch_stride: Tuple[int, int] = (1, 1),
      heatmap_mode: str = "Target",
      tr_lo: float = 0.65,
      tr_hi: float = 0.85,
      num_xforms_mask: int = 100,
      max_mask_size: int = -1,
      beta: float = 1.0,
      eta: float = 500,
      num_xforms_boost: int = 100,
      num_boost_queries: int = 20000,
      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 GRAPHITEBlackbox attack instance.
  
      :param classifier: A trained classifier.
      :param noise_size: The resolution to generate perturbations in (w, h).
      :param net_size: The resolution to resize images to before feeding to the model in (w, h).
      :param heat_patch_size: The size of the heatmap patches in (w, h).
      :param heat_patch_stride: The stride of the heatmap patching in (w, h).
      :param heatmap_mode: The mode of heatmap in ['Target', 'Random'].
      :param tr_lo: tr_lo, threshold for fine-grained reduction.
      :param tr_hi: tr_hi, threshold for coarse-grained reduction.
      :param num_xforms_mask: The number of transforms to use in mask generation.
      :param max_mask_size: Optionally specify that you just want to optimize until a mask size of <= max_mask_size.
      :param beta: The parameter beta for RGF optimization in boosting.
      :param eta: The step size for RGF optimization in boosting.
      :param num_xforms_boost: The number of transforms to use in boosting.
      :param num_boost_queries: The number of queries to use in boosting.
      :param rotation_range: The range of the rotation in the perspective transform.
      :param dist_range: The range of the distance (in ft) to be added to the focal length in 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.noise_size = noise_size
      self.net_size = net_size
      self.heat_patch_size = heat_patch_size
      self.heat_patch_stride = heat_patch_stride
      self.heatmap_mode = heatmap_mode
      self.batch_size = batch_size
      self.tr_lo = tr_lo
      self.tr_hi = tr_hi
      self.num_xforms_mask = num_xforms_mask
      self.max_mask_size = max_mask_size
      self.beta = beta
      self.eta = eta
      self.num_xforms_boost = num_xforms_boost
      self.num_boost_queries = num_boost_queries
      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._check_params()
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Optional, Tuple, Union, TYPE_CHECKING, List
  import random
  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
  from art.attacks.evasion.graphite.utils import convert_to_network, get_transform_params, add_noise, get_transformed_images, run_predictions, score_fn
label_desc: Use image node_id 1 to create a new GRAPHITEBlackbox object from inherited base classes: EvasionAttack with example: obj = GRAPHITEBlackbox(classifier, noise_size, net_size, heat_patch_size, heat_patch_stride, heatmap_mode, tr_lo, tr_hi, num_xforms_mask, max_mask_size, beta, eta, num_xforms_boost, num_boost_queries, rotation_range, dist_range, gamma_range, crop_percent_range, off_x_range, off_y_range, blur_kernels, batch_size)