class_docstr: Vision transformer backbone.
  
  A PyTorch impl of : `An Image is Worth 16x16 Words: Transformers for
      Image Recognition at Scale` - https://arxiv.org/abs/2010.11929
  
  Args:
      img_size (tuple): input image size. Default: (224, 224).
      patch_size (int, tuple): patch size. Default: 16.
      in_channels (int): number of input channels. Default: 3.
      embed_dim (int): embedding dimension. Default: 768.
      depth (int): depth of transformer. Default: 12.
      num_heads (int): number of attention heads. Default: 12.
      mlp_ratio (int): ratio of mlp hidden dim to embedding dim.
          Default: 4.
      out_indices (list | tuple | int): Output from which stages.
          Default: -1.
      qkv_bias (bool): enable bias for qkv if True. Default: True.
      qk_scale (float): override default qk scale of head_dim ** -0.5 if set.
      drop_rate (float): dropout rate. Default: 0.
      attn_drop_rate (float): attention dropout rate. Default: 0.
      drop_path_rate (float): Rate of DropPath. Default: 0.
      norm_cfg (dict): Config dict for normalization layer.
          Default: dict(type='LN', eps=1e-6, requires_grad=True).
      act_cfg (dict): Config dict for activation layer.
          Default: dict(type='GELU').
      norm_eval (bool): Whether to set norm layers to eval mode, namely,
          freeze running stats (mean and var). Note: Effect on Batch Norm
          and its variants only. Default: False.
      final_norm (bool):  Whether to add a additional layer to normalize
          final feature map. Default: False.
      interpolate_mode (str): Select the interpolate mode for position
          embeding vector resize. Default: bicubic.
      with_cls_token (bool): If concatenating class token into image tokens
          as transformer input. Default: True.
      with_cp (bool): Use checkpoint or not. Using checkpoint
          will save some memory while slowing down the training speed.
          Default: False.
class_docstr_tok: ["Vision","transformer","backbone",".","A","PyTorch","impl","of",":","`","An","Image","is","Worth","16x16","Words",":","Transformers","for","Image","Recognition","at","Scale","`","-","https",":","\/\/arxiv.org\/abs\/2010.11929","Args",":","img_size","(","tuple",")",":","input","image","size",".","Default",":","(","224",",","224",")",".","patch_size","(","int",",","tuple",")",":","patch","size",".","Default",":","16.","in_channels","(","int",")",":","number","of","input","channels",".","Default",":","3.","embed_dim","(","int",")",":","embedding","dimension",".","Default",":","768.","depth","(","int",")",":","depth","of","transformer",".","Default",":","12.","num_heads","(","int",")",":","number","of","attention","heads",".","Default",":","12.","mlp_ratio","(","int",")",":","ratio","of","mlp","hidden","dim","to","embedding","dim",".","Default",":","4.","out_indices","(","list","|","tuple","|","int",")",":","Output","from","which","stages",".","Default",":","-1.","qkv_bias","(","bool",")",":","enable","bias","for","qkv","if","True",".","Default",":","True",".","qk_scale","(","float",")",":","override","default","qk","scale","of","head_dim","*","*","-0.5","if","set",".","drop_rate","(","float",")",":","dropout","rate",".","Default",":","0.","attn_drop_rate","(","float",")",":","attention","dropout","rate",".","Default",":","0.","drop_path_rate","(","float",")",":","Rate","of","DropPath",".","Default",":","0.","norm_cfg","(","dict",")",":","Config","dict","for","normalization","layer",".","Default",":","dict","(","type='LN","'",",","eps=1e-6",",","requires_grad=True",")",".","act_cfg","(","dict",")",":","Config","dict","for","activation","layer",".","Default",":","dict","(","type='GELU","'",")",".","norm_eval","(","bool",")",":","Whether","to","set","norm","layers","to","eval","mode",",","namely",",","freeze","running","stats","(","mean","and","var",")",".","Note",":","Effect","on","Batch","Norm","and","its","variants","only",".","Default",":","False",".","final_norm","(","bool",")",":","Whether","to","add","a","additional","layer","to","normalize","final","feature","map",".","Default",":","False",".","interpolate_mode","(","str",")",":","Select","the","interpolate","mode","for","position","embeding","vector","resize",".","Default",":","bicubic",".","with_cls_token","(","bool",")",":","If","concatenating","class","token","into","image","tokens","as","transformer","input",".","Default",":","True",".","with_cp","(","bool",")",":","Use","checkpoint","or","not",".","Using","checkpoint","will","save","some","memory","while","slowing","down","the","training","speed",".","Default",":","False","."]
code: def __init__(
      self,
      img_size=(224, 224),
      patch_size=16,
      in_channels=3,
      embed_dim=768,
      depth=12,
      num_heads=12,
      mlp_ratio=4,
      out_indices=11,
      qkv_bias=True,
      qk_scale=None,
      drop_rate=0.0,
      attn_drop_rate=0.0,
      drop_path_rate=0.0,
      norm_cfg=dict(type="LN", eps=1e-6, requires_grad=True),
      act_cfg=dict(type="GELU"),
      norm_eval=False,
      final_norm=False,
      with_cls_token=True,
      interpolate_mode="bicubic",
      with_cp=False,
  ):
      super(VisionTransformer, self).__init__()
      self.img_size = img_size
      self.patch_size = patch_size
      self.features = self.embed_dim = embed_dim
      self.patch_embed = PatchEmbed(
          img_size=img_size,
          patch_size=patch_size,
          in_channels=in_channels,
          embed_dim=embed_dim,
      )
  
      self.with_cls_token = with_cls_token
      self.cls_token = nn.Parameter(torch.zeros(1, 1, self.embed_dim))
      self.pos_embed = nn.Parameter(
          torch.zeros(1, self.patch_embed.num_patches + 1, embed_dim)
      )
      self.pos_drop = nn.Dropout(p=drop_rate)
  
      if isinstance(out_indices, int):
          self.out_indices = [out_indices]
      elif isinstance(out_indices, list) or isinstance(
          out_indices, tuple
      ):
          self.out_indices = out_indices
      else:
          raise TypeError(
              "out_indices must be type of int, list or tuple"
          )
  
      dpr = [
          x.item() for x in torch.linspace(0, drop_path_rate, depth)
      ]  # stochastic depth decay rule
      self.blocks = nn.ModuleList(
          [
              Block(
                  dim=embed_dim,
                  num_heads=num_heads,
                  mlp_ratio=mlp_ratio,
                  qkv_bias=qkv_bias,
                  qk_scale=qk_scale,
                  drop=dpr[i],
                  attn_drop=attn_drop_rate,
                  act_cfg=act_cfg,
                  norm_cfg=norm_cfg,
                  with_cp=with_cp,
              )
              for i in range(depth)
          ]
      )
  
      self.interpolate_mode = interpolate_mode
      self.final_norm = final_norm
      if final_norm:
          _, self.norm = build_norm_layer(norm_cfg, embed_dim)
  
      self.norm_eval = norm_eval
      self.with_cp = with_cp
  
imports: import math
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.utils.checkpoint
  from annotator.uniformer.mmcv.cnn import Conv2d, Linear, build_activation_layer, build_norm_layer, constant_init, kaiming_init, normal_init
  from annotator.uniformer.mmcv.runner import _load_checkpoint
  from annotator.uniformer.mmcv.utils.parrots_wrapper import _BatchNorm
  from annotator.uniformer.mmseg.utils import get_root_logger
  from ..builder import BACKBONES
  from ..utils import DropPath, trunc_normal_
label_desc: Use image node_id 1 to create a new VisionTransformer object from inherited base classes: nn with example: obj = VisionTransformer(img_size, patch_size, in_channels, embed_dim, depth, num_heads, mlp_ratio, out_indices, qkv_bias, qk_scale, drop_rate, attn_drop_rate, drop_path_rate, norm_cfg, act_cfg, norm_eval, final_norm, with_cls_token, interpolate_mode, with_cp)