class_docstr: Vision Transformer with support for patch or hybrid CNN input stage
      
class_docstr_tok: ["Vision","Transformer","with","support","for","patch","or","hybrid","CNN","input","stage"]
code: def __init__(
      self,
      img_size: int = 112,
      patch_size: int = 16,
      in_channels: int = 3,
      num_classes: int = 1000,
      embed_dim: int = 768,
      depth: int = 12,
      num_heads: int = 12,
      mlp_ratio: float = 4.0,
      qkv_bias: bool = False,
      qk_scale: Optional[None] = None,
      drop_rate: float = 0.0,
      attn_drop_rate: float = 0.0,
      drop_path_rate: float = 0.0,
      hybrid_backbone: Optional[None] = None,
      norm_layer: str = "ln",
      mask_ratio=0.1,
      using_checkpoint=False,
  ):
      super().__init__()
      self.num_classes = num_classes
      # num_features for consistency with other models
      self.num_features = self.embed_dim = embed_dim
  
      if hybrid_backbone is not None:
          raise ValueError
      else:
          self.patch_embed = PatchEmbed(
              img_size=img_size,
              patch_size=patch_size,
              in_channels=in_channels,
              embed_dim=embed_dim,
          )
      self.mask_ratio = mask_ratio
      self.using_checkpoint = using_checkpoint
      num_patches = self.patch_embed.num_patches
      self.num_patches = num_patches
  
      self.pos_embed = nn.Parameter(
          torch.zeros(1, num_patches, embed_dim)
      )
      self.pos_drop = nn.Dropout(p=drop_rate)
  
      # stochastic depth decay rule
      dpr = [x.item() for x in torch.linspace(0, drop_path_rate, depth)]
      patch_n = (img_size // patch_size) ** 2
      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=drop_rate,
                  attn_drop=attn_drop_rate,
                  drop_path=dpr[i],
                  norm_layer=norm_layer,
                  num_patches=num_patches,
                  patch_n=patch_n,
              )
              for i in range(depth)
          ]
      )
      self.extra_gflops = 0.0
      for _block in self.blocks:
          self.extra_gflops += _block.extra_gflops
  
      if norm_layer == "ln":
          self.norm = nn.LayerNorm(embed_dim)
      elif norm_layer == "bn":
          self.norm = VITBatchNorm(self.num_patches)
  
      # features head
      self.feature = nn.Sequential(
          nn.Linear(
              in_features=embed_dim * num_patches,
              out_features=embed_dim,
              bias=False,
          ),
          nn.BatchNorm1d(num_features=embed_dim, eps=2e-5),
          nn.Linear(
              in_features=embed_dim,
              out_features=num_classes,
              bias=False,
          ),
          nn.BatchNorm1d(num_features=num_classes, eps=2e-5),
      )
  
      self.mask_token = nn.Parameter(torch.zeros(1, 1, embed_dim))
      torch.nn.init.normal_(self.mask_token, std=0.02)
      trunc_normal_(self.pos_embed, std=0.02)
      # trunc_normal_(self.cls_token, std=.02)
      self.apply(self._init_weights)
  
imports: import torch
  import torch.nn
  from timm.models.layers import DropPath, to_2tuple, trunc_normal_
  from typing import Optional, Callable
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, num_classes, embed_dim, depth, num_heads, mlp_ratio, qkv_bias, qk_scale, drop_rate, attn_drop_rate, drop_path_rate, hybrid_backbone, norm_layer, mask_ratio, using_checkpoint)