class_docstr: Vision Transformer with support for patch input
      
class_docstr_tok: ["Vision","Transformer","with","support","for","patch","input"]
code: def init_weight(self):
      pretrained = self.pretrained
      if pretrained:
          if "http" in pretrained:
              path = paddle.utils.download.get_weights_path_from_url(
                  pretrained
              )
          else:
              path = pretrained
  
          load_state_dict = paddle.load(path)
          model_state_dict = self.state_dict()
          pos_embed_name = "pos_embed"
  
          if (
              pos_embed_name in load_state_dict.keys()
              and self.use_abs_pos_emb
          ):
              load_pos_embed = paddle.to_tensor(
                  load_state_dict[pos_embed_name], dtype="float32"
              )
              if self.pos_embed.shape != load_pos_embed.shape:
                  pos_size = int(math.sqrt(load_pos_embed.shape[1] - 1))
                  model_state_dict[
                      pos_embed_name
                  ] = self.resize_pos_embed(
                      load_pos_embed,
                      (pos_size, pos_size),
                      (self.pos_h, self.pos_w),
                  )
  
                  # self.set_state_dict(model_state_dict)
                  load_state_dict[pos_embed_name] = model_state_dict[
                      pos_embed_name
                  ]
  
                  print(
                      "Load pos_embed and resize it from {} to {} .".format(
                          load_pos_embed.shape, self.pos_embed.shape
                      )
                  )
  
          self.set_state_dict(load_state_dict)
          print("Load load_state_dict....")
  
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 3 for calling the VisionTransformer2D obj's underlying member method code with example usage: obj.init_weight() without return types