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: Drops the tokens which correspond to fully masked inputs
  
  :param x: Input data
  :param indexes: positions to be ablated
  :return: Input with tokens dropped where the input was fully ablated.
docstr_tok: ["Drops","the","tokens","which","correspond","to","fully","masked","inputs",":","param","x",":","Input","data",":","param","indexes",":","positions","to","be","ablated",":","return",":","Input","with","tokens","dropped","where","the","input","was","fully","ablated","."]
code: def drop_tokens(
      x: torch.Tensor, indexes: torch.Tensor
  ) -> torch.Tensor:
      """
      Drops the tokens which correspond to fully masked inputs
  
      :param x: Input data
      :param indexes: positions to be ablated
      :return: Input with tokens dropped where the input was fully ablated.
      """
      x_no_cl, cls_token = x[:, 1:], x[:, 0:1]
      shape = x_no_cl.shape
  
      # reshape to temporarily remove batch
      x_no_cl = torch.reshape(x_no_cl, shape=(-1, shape[-1]))
      indexes = torch.reshape(indexes, shape=(-1,))
      indexes = indexes.nonzero(as_tuple=True)[0]
      x_no_cl = torch.index_select(x_no_cl, dim=0, index=indexes)
      x_no_cl = torch.reshape(x_no_cl, shape=(shape[0], -1, shape[-1]))
      return torch.cat((cls_token, x_no_cl), dim=1)
  
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 2 for calling the PyTorchVisionTransformer obj's underlying member method code with example usage: obj.drop_tokens(x, indexes) and returns: torch