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: The forward pass of the ViT.
  
  :param x: Input data.
  :return: The input processed by the ViT backbone
docstr_tok: ["The","forward","pass","of","the","ViT",".",":","param","x",":","Input","data",".",":","return",":","The","input","processed","by","the","ViT","backbone"]
code: def forward_features(self, x: torch.Tensor) -> torch.Tensor:
      """
      The forward pass of the ViT.
  
      :param x: Input data.
      :return: The input processed by the ViT backbone
      """
  
      ablated_input = False
      if x.shape[1] == self.in_chans + 1:
          ablated_input = True
  
      if ablated_input:
          x, ablation_mask = (
              x[:, : self.in_chans],
              x[:, self.in_chans : self.in_chans + 1],
          )
  
      x = self.patch_embed(x)
      x = self._pos_embed(x)
  
      if self.to_drop_tokens and ablated_input:
          ones = self.ablation_mask_embedder(ablation_mask)
          to_drop = torch.sum(ones, dim=2)
          indexes = torch.gt(torch.where(to_drop > 1, 1, 0), 0)
          x = self.drop_tokens(x, indexes)
  
      x = self.norm_pre(x)
      x = self.blocks(x)
      return self.norm(x)
  
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 3 for calling the PyTorchVisionTransformer obj's underlying member method code with example usage: obj.forward_features(x) and returns: self