class_docstr: Vision Transformer with support for patch input
      
class_docstr_tok: ["Vision","Transformer","with","support","for","patch","input"]
code: def __init__(
      self,
      img_size=224,
      patch_size=16,
      in_chans=3,
      class_dim=0,
      embed_dim=768,
      depth=12,
      num_heads=12,
      mlp_ratio=4,
      qkv_bias=False,
      qk_scale=None,
      drop_rate=0.0,
      attn_drop_rate=0.0,
      drop_path_rate=0.0,
      norm_layer="nn.LayerNorm",
      epsilon=1e-5,
      **args,
  ):
      super().__init__()
      self.class_dim = class_dim
  
      self.num_features = self.embed_dim = embed_dim
  
      self.patch_embed = PatchEmbed(
          img_size=img_size,
          patch_size=patch_size,
          in_chans=in_chans,
          embed_dim=embed_dim,
      )
      num_patches = self.patch_embed.num_patches
  
      scale = embed_dim**-0.5
      self.class_embedding = self.create_parameter(
          shape=(1, 1, embed_dim), default_initializer=Normal(std=scale)
      )
      self.positional_embedding = self.create_parameter(
          shape=(1, num_patches + 1, embed_dim),
          default_initializer=Normal(std=scale),
      )
      self.add_parameter(
          "positional_embedding", self.positional_embedding
      )
      self.add_parameter("class_embedding", self.class_embedding)
      self.pos_drop = nn.Dropout(p=drop_rate)
  
      dpr = np.linspace(0, drop_path_rate, depth)
  
      self.norm_pre = eval(norm_layer)(embed_dim, epsilon=epsilon)
  
      self.blocks = nn.LayerList(
          [
              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,
                  epsilon=epsilon,
              )
              for i in range(depth)
          ]
      )
  
      self.norm_post = eval(norm_layer)(embed_dim, epsilon=epsilon)
  
      ## Classifier head
      # self.head = nn.Linear(embed_dim,
      #                      class_dim) if class_dim > 0 else Identity()
  
      trunc_normal_(self.positional_embedding)
      trunc_normal_(self.class_embedding)
      self.apply(self._init_weights)
  
imports: import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from paddle.nn import Layer
  from paddle.nn import Linear
  from paddle.nn.initializer import Constant
  from paddle.nn.initializer import Normal
  from paddle.nn.initializer import TruncatedNormal
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_chans, class_dim, embed_dim, depth, num_heads, mlp_ratio, qkv_bias, qk_scale, drop_rate, attn_drop_rate, drop_path_rate, norm_layer, epsilon)