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=(1024, 1024),
      patch_size=16,
      in_chans=3,
      embed_dim=768,
      depth=12,
      num_heads=12,
      mlp_ratio=4,
      qkv_bias=False,
      attn_bias=False,
      qk_scale=None,
      init_values=None,
      drop_rate=0.0,
      attn_drop_rate=0.0,
      drop_path_rate=0.0,
      act_layer="nn.GELU",
      norm_layer="nn.LayerNorm",
      lr_decay_rate=1.0,
      global_attn_indexes=(2, 5, 8, 11),
      use_abs_pos=False,
      use_rel_pos=False,
      use_abs_pos_emb=False,
      use_sincos_pos_emb=False,
      rel_pos_zero_init=True,
      epsilon=1e-5,
      final_norm=False,
      pretrained=None,
      window_size=None,
      out_indices=(11,),
      with_fpn=False,
      use_checkpoint=False,
      *args,
      **kwargs,
  ):
      super().__init__()
      self.img_size = img_size
      self.patch_size = patch_size
      self.embed_dim = embed_dim
      self.num_heads = num_heads
      self.depth = depth
      self.global_attn_indexes = global_attn_indexes
      self.epsilon = epsilon
      self.with_fpn = with_fpn
      self.use_checkpoint = use_checkpoint
  
      self.patch_h = img_size[0] // patch_size
      self.patch_w = img_size[1] // patch_size
      self.num_patches = self.patch_h * self.patch_w
      self.use_abs_pos = use_abs_pos
      self.use_abs_pos_emb = use_abs_pos_emb
  
      self.patch_embed = PatchEmbed(
          img_size=img_size,
          patch_size=patch_size,
          in_chans=in_chans,
          embed_dim=embed_dim,
      )
  
      dpr = np.linspace(0, drop_path_rate, depth)
      if use_checkpoint:
          paddle.seed(0)
  
      if use_abs_pos_emb:
          self.pos_w = self.patch_embed.num_patches_in_w
          self.pos_h = self.patch_embed.num_patches_in_h
          self.pos_embed = self.create_parameter(
              shape=(1, self.pos_w * self.pos_h + 1, embed_dim),
              default_initializer=paddle.nn.initializer.TruncatedNormal(
                  std=0.02
              ),
          )
      elif use_sincos_pos_emb:
          pos_embed = self.get_2d_sincos_position_embedding(
              self.patch_h, self.patch_w
          )
  
          self.pos_embed = pos_embed
          self.pos_embed = self.create_parameter(shape=pos_embed.shape)
          self.pos_embed.set_value(pos_embed.numpy())
          self.pos_embed.stop_gradient = True
      else:
          self.pos_embed = None
  
      self.blocks = nn.LayerList(
          [
              Block(
                  embed_dim,
                  num_heads=num_heads,
                  mlp_ratio=mlp_ratio,
                  qkv_bias=qkv_bias,
                  attn_bias=attn_bias,
                  qk_scale=qk_scale,
                  drop=drop_rate,
                  attn_drop=attn_drop_rate,
                  drop_path=dpr[i],
                  use_rel_pos=use_rel_pos,
                  rel_pos_zero_init=rel_pos_zero_init,
                  window_size=None
                  if i in self.global_attn_indexes
                  else window_size,
                  input_size=[self.patch_h, self.patch_w],
                  act_layer=act_layer,
                  lr_factor=self.get_vit_lr_decay_rate(
                      i, lr_decay_rate
                  ),
                  norm_layer=norm_layer,
                  init_values=init_values,
                  epsilon=epsilon,
              )
              for i in range(depth)
          ]
      )
  
      assert len(out_indices) <= 4, "out_indices out of bound"
      self.out_indices = out_indices
      self.pretrained = pretrained
      self.init_weight()
  
      self.out_channels = [embed_dim for _ in range(len(out_indices))]
      self.out_strides = (
          [4, 8, 16, 32][-len(out_indices) :]
          if with_fpn
          else [patch_size for _ in range(len(out_indices))]
      )
      self.norm = Identity()
      if self.with_fpn:
          self.init_fpn(
              embed_dim=embed_dim,
              patch_size=patch_size,
              out_with_norm=final_norm,
          )
  
imports: import paddle
  import paddle.nn
  import paddle.nn.functional
  import numpy
  import math
  from paddle import ParamAttr
  from paddle.regularizer import L2Decay
  from paddle.nn.initializer import Constant, TruncatedNormal
  from ppdet.modeling.shape_spec import ShapeSpec
  from ppdet.core.workspace import register, serializable
  from .transformer_utils import zeros_, DropPath, Identity, window_partition, window_unpartition
  from ..initializer import linear_init_
label_desc: Use image node_id 1 to create a new VisionTransformer2D object from inherited base classes: nn with example: obj = VisionTransformer2D(img_size, patch_size, in_chans, embed_dim, depth, num_heads, mlp_ratio, qkv_bias, attn_bias, qk_scale, init_values, drop_rate, attn_drop_rate, drop_path_rate, act_layer, norm_layer, lr_decay_rate, global_attn_indexes, use_abs_pos, use_rel_pos, use_abs_pos_emb, use_sincos_pos_emb, rel_pos_zero_init, epsilon, final_norm, pretrained, window_size, out_indices, with_fpn, use_checkpoint)