class_docstr: Vision Transformer Model
  Args:
      img_size (`int`):
          Image height or width (height=width).
      patch_size (`int`):
          Patch height or width (height=width).
      in_c (`int`):
          Number of image channels.
      num_classes (`int`):
          Number of classes.
      embed_dim (`int`):
          Number of features.
      depth (`int`):
          Number of blocks.
      num_heads (`int`):
          Number of heads for Multi-Attention layer.
      mlp_ratio (`float`):
          Mlp ratio.
      qkv_bias (`bool`):
          If add bias to qkv layer.
      qk_scale (`float`):
          Number to scale qk
      representation_size (`int`):
          Size of representations.
      drop_ratio (`float`):
          Drop rate of a block
      attn_drop_ratio (`float`):
          Drop rate of attention layer
      drop_path_ratio (`float`):
          Drop rate of drop_path layer
      embed_layer (`nn.Module`):
          Patch embedding layer.
      norm_layer (`nn.Module`):
          Normalization layer.
      act_layer(`nn.Module`):
          Activation layer.
class_docstr_tok: ["Vision","Transformer","Model","Args",":","img_size","(","`","int","`",")",":","Image","height","or","width","(","height=width",")",".","patch_size","(","`","int","`",")",":","Patch","height","or","width","(","height=width",")",".","in_c","(","`","int","`",")",":","Number","of","image","channels",".","num_classes","(","`","int","`",")",":","Number","of","classes",".","embed_dim","(","`","int","`",")",":","Number","of","features",".","depth","(","`","int","`",")",":","Number","of","blocks",".","num_heads","(","`","int","`",")",":","Number","of","heads","for","Multi-Attention","layer",".","mlp_ratio","(","`","float","`",")",":","Mlp","ratio",".","qkv_bias","(","`","bool","`",")",":","If","add","bias","to","qkv","layer",".","qk_scale","(","`","float","`",")",":","Number","to","scale","qk","representation_size","(","`","int","`",")",":","Size","of","representations",".","drop_ratio","(","`","float","`",")",":","Drop","rate","of","a","block","attn_drop_ratio","(","`","float","`",")",":","Drop","rate","of","attention","layer","drop_path_ratio","(","`","float","`",")",":","Drop","rate","of","drop_path","layer","embed_layer","(","`","nn.Module","`",")",":","Patch","embedding","layer",".","norm_layer","(","`","nn.Module","`",")",":","Normalization","layer",".","act_layer","(","`","nn.Module","`",")",":","Activation","layer","."]
code: def __init__(
      self,
      img_size=224,
      patch_size=16,
      in_c=3,
      num_classes=1000,
      embed_dim=768,
      depth=12,
      num_heads=12,
      mlp_ratio=4.0,
      qkv_bias=True,
      qk_scale=None,
      representation_size=None,
      drop_ratio=0.0,
      attn_drop_ratio=0.0,
      drop_path_ratio=0.0,
      embed_layer=PatchEmbed2D,
      norm_layer=None,
      act_layer=None,
  ):
      super().__init__()
      self.num_classes = num_classes
      self.num_features = (
          self.embed_dim
      ) = embed_dim  # num_features for consistency with other models
      self.num_tokens = 1
      norm_layer = norm_layer or partial(LayerNorm, eps=1e-6)
      act_layer = act_layer or GELU
  
      self.patch_embed = embed_layer(
          img_size=img_size,
          patch_size=patch_size,
          in_chans=in_c,
          embed_dim=embed_dim,
      )
      num_patches = self.patch_embed.num_patches
  
      self.cls_token = nn.Parameter(torch.zeros(1, 1, embed_dim))
      self.pos_embed = nn.Parameter(
          torch.zeros(1, num_patches + self.num_tokens, embed_dim)
      )
      self.pos_drop = nn.Dropout(p=drop_ratio)
  
      dpr = [
          x.item() for x in torch.linspace(0, drop_path_ratio, depth)
      ]  # stochastic depth decay rule
      self.blocks = nn.Sequential(
          *[
              Block(
                  dim=embed_dim,
                  num_heads=num_heads,
                  mlp_ratio=mlp_ratio,
                  qkv_bias=qkv_bias,
                  qk_scale=qk_scale,
                  drop_ratio=drop_ratio,
                  attn_drop_ratio=attn_drop_ratio,
                  drop_path_ratio=dpr[i],
                  norm_layer=norm_layer,
                  act_layer=act_layer,
              )
              for i in range(depth)
          ]
      )
      self.norm = norm_layer(embed_dim)
  
      # Representation layer
      if representation_size:
          self.has_logits = True
          self.num_features = representation_size
          self.pre_logits = nn.Sequential(
              OrderedDict(
                  [
                      (
                          "fc",
                          Linear(embed_dim, representation_size),
                      ),  # pylint: disable=too-many-function-args
                      ("act", nn.Tanh()),
                  ]
              )
          )
      else:
          self.has_logits = False
          self.pre_logits = nn.Identity()
  
      # Classifier head(s)
      self.head = (
          Linear(self.num_features, num_classes)
          if num_classes > 0
          else nn.Identity()
      )  # pylint: disable=too-many-function-args
  
      # Weight init
      nn.init.trunc_normal_(self.pos_embed, std=0.02)
      nn.init.trunc_normal_(self.cls_token, std=0.02)
      self.apply(init_vit_weights)
  
      self.pool = IndexSelect()
      self.add = Add()
      self.inp_grad = None
  
file_path: towhee/towhee/models/vit/vit.py
imports: import torch
  from torch import nn
  from torch.utils import model_zoo
  from functools import partial
  from collections import OrderedDict
  from towhee.models.utils.init_vit_weights import init_vit_weights
  from towhee.models.layers.patch_embed2d import PatchEmbed2D
  from .vit_utils import get_configs
  from .vit_block import Block
  from towhee.models.layers.layers_with_relprop import LayerNorm, GELU, Linear, IndexSelect, Add
label_desc: Use image node_id 1 to create a new VitModel object from inherited base classes: nn with example: obj = VitModel(img_size, patch_size, in_c, num_classes, embed_dim, depth, num_heads, mlp_ratio, qkv_bias, qk_scale, representation_size, drop_ratio, attn_drop_ratio, drop_path_ratio, embed_layer, norm_layer, act_layer)