class_docstr: Model-specific class to define the forward pass of the Vision Transformer (ViT) in PyTorch.
class_docstr_tok: ["Model-specific","class","to","define","the","forward","pass","of","the","Vision","Transformer","(","ViT",")","in","PyTorch","."]
docstr: Create a PyTorchVisionTransformer instance
  
  :param kwargs: keyword arguments required to create the mask embedder and the vision transformer class
docstr_tok: ["Create","a","PyTorchVisionTransformer","instance",":","param","kwargs",":","keyword","arguments","required","to","create","the","mask","embedder","and","the","vision","transformer","class"]
code: def __init__(self, **kwargs):
      """
      Create a PyTorchVisionTransformer instance
  
      :param kwargs: keyword arguments required to create the mask embedder and the vision transformer class
      """
      self.to_drop_tokens = kwargs["drop_tokens"]
  
      if (
          kwargs["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}")
  
      del kwargs["drop_tokens"]
      del kwargs["device_type"]
  
      super().__init__(**kwargs)
      self.ablation_mask_embedder.create(device=self.device, **kwargs)
  
      self.in_chans = kwargs["in_chans"]
      self.img_size = kwargs["img_size"]
  
file_path: adversarial-robustness-toolbox/art/estimators/certification/derandomized_smoothing/vision_transformers/pytorch.py
imports: from typing import Optional
  import torch
  from timm.models.vision_transformer import VisionTransformer
label_desc: Use image node_id 1 to create a new PyTorchVisionTransformer object from inherited base classes: VisionTransformer with example: obj = PyTorchVisionTransformer()