class_docstr: Pure Pytorch implementation of block ablation.
docstr: Creates a column ablator
  
  :param ablation_size: The size of the block we will retain.
  :param channels_first: If the input is in channels first format. Currently required to be True.
  :param mode: If we are running the algorithm using a CNN or VIT.
  :param to_reshape: If the input requires reshaping.
  :param original_shape: Original shape of the input.
  :param output_shape: Input shape expected by the ViT. Usually means upscaling the input to 224 x 224.
  :param algorithm: Either 'salman2021' or 'levine2020'.
  :param device_type: Type of device on which the classifier is run, either `gpu` or `cpu`.
docstr_tok: ["Creates","a","column","ablator",":","param","ablation_size",":","The","size","of","the","block","we","will","retain",".",":","param","channels_first",":","If","the","input","is","in","channels","first","format",".","Currently","required","to","be","True",".",":","param","mode",":","If","we","are","running","the","algorithm","using","a","CNN","or","VIT",".",":","param","to_reshape",":","If","the","input","requires","reshaping",".",":","param","original_shape",":","Original","shape","of","the","input",".",":","param","output_shape",":","Input","shape","expected","by","the","ViT",".","Usually","means","upscaling","the","input","to","224","x","224.",":","param","algorithm",":","Either","'salman2021","'","or","'levine2020","'",".",":","param","device_type",":","Type","of","device","on","which","the","classifier","is","run",",","either","`","gpu","`","or","`","cpu","`","."]
code: def __init__(
      self,
      ablation_size: int,
      channels_first: bool,
      mode: str,
      to_reshape: bool,
      original_shape: Optional[Tuple] = None,
      output_shape: Optional[Tuple] = None,
      algorithm: str = "salman2021",
      device_type: str = "gpu",
  ):
      """
      Creates a column ablator
  
      :param ablation_size: The size of the block we will retain.
      :param channels_first: If the input is in channels first format. Currently required to be True.
      :param mode: If we are running the algorithm using a CNN or VIT.
      :param to_reshape: If the input requires reshaping.
      :param original_shape: Original shape of the input.
      :param output_shape: Input shape expected by the ViT. Usually means upscaling the input to 224 x 224.
      :param algorithm: Either 'salman2021' or 'levine2020'.
      :param device_type: Type of device on which the classifier is run, either `gpu` or `cpu`.
      """
      super().__init__()
  
      self.ablation_size = ablation_size
      self.channels_first = channels_first
      self.to_reshape = to_reshape
      self.add_ablation_mask = False
      self.additional_channels = False
      self.algorithm = algorithm
      self.original_shape = original_shape
  
      if self.algorithm == "levine2020":
          self.additional_channels = True
      if self.algorithm == "salman2021" and mode == "ViT":
          self.add_ablation_mask = True
  
      if device_type == "cpu" or not torch.cuda.is_available():
          self.device = torch.device("cpu")
      else:  # pragma: no cover
          cuda_idx = torch.cuda.current_device()
          self.device = torch.device(f"cuda:{cuda_idx}")
  
      if original_shape is not None and output_shape is not None:
          self.upsample = UpSamplerPyTorch(
              input_size=original_shape[1], final_size=output_shape[1]
          )
  
imports: from typing import Optional, Union, Tuple
  import random
  import numpy
  import torch
  from art.estimators.certification.derandomized_smoothing.ablators.ablate import BaseAblator
label_desc: Use image node_id 1 to create a new BlockAblatorPyTorch object from inherited base classes: torch.nn, BaseAblator with example: obj = BlockAblatorPyTorch(ablation_size, channels_first, mode, to_reshape, original_shape, output_shape, algorithm, device_type)