code: def build_clip_model(pretrained_model):
      state_dict = load_pretrain_clip(pretrained_model)
      vit = "visual.proj" in state_dict
      if vit:
          vision_width = state_dict["visual.conv1.weight"].shape[0]
          vision_layers = len(
              [
                  k
                  for k in state_dict.keys()
                  if k.startswith("visual.")
                  and k.endswith(".attn.q_proj.weight")
              ]
          )
          vision_patch_size = state_dict["visual.conv1.weight"].shape[
              -1
          ]
          grid_size = round(
              (state_dict["visual.positional_embedding"].shape[0] - 1)
              ** 0.5
          )
          image_resolution = vision_patch_size * grid_size
      else:
          """Class Method: *.split, not convert, please check whether it is torch.Tensor.*/Optimizer.*/nn.Module.*, and convert manually"""
          counts: list = [
              len(
                  set(
                      k.split(".")[2]
                      for k in state_dict
                      if k.startswith(f"visual.layer{b}")
                  )
              )
              for b in [1, 2, 3, 4]
          ]
          vision_layers = tuple(counts)
          vision_width = state_dict[
              "visual.layer1.0.conv1.weight"
          ].shape[0]
          output_width = round(
              (
                  state_dict[
                      "visual.attnpool.positional_embedding"
                  ].shape[0]
                  - 1
              )
              ** 0.5
          )
          vision_patch_size = None
          assert (
              output_width**2 + 1
              == state_dict[
                  "visual.attnpool.positional_embedding"
              ].shape[0]
          )
          image_resolution = output_width * 32
      embed_dim = state_dict["text_projection"].shape[1]
      context_length = state_dict["positional_embedding"].shape[0]
      vocab_size = state_dict["token_embedding.weight"].shape[0]
      transformer_width = state_dict["ln_final.weight"].shape[0]
      transformer_heads = transformer_width // 64
      """Class Method: *.split, not convert, please check whether it is torch.Tensor.*/Optimizer.*/nn.Module.*, and convert manually"""
      transformer_layers = len(
          set(
              k.split(".")[2]
              for k in state_dict
              if k.startswith("transformer.resblocks")
          )
      )
      model = CLIP(
          embed_dim,
          image_resolution,
          vision_layers,
          vision_width,
          vision_patch_size,
          context_length,
          vocab_size,
          transformer_width,
          transformer_heads,
          transformer_layers,
      )
      for key in ["input_resolution", "context_length", "vocab_size"]:
          if key in state_dict:
              del state_dict[key]
      # convert_weights(model)
      model.eval()
      model.set_state_dict(state_dict=state_dict)
      return model, _transform(model.visual.input_resolution)
  
imports: from collections import OrderedDict
  from typing import Tuple, Union
  import numpy
  import paddle
  from paddle.nn.initializer import Constant
  from paddle.vision.transforms import Compose, Resize, CenterCrop, ToTensor, Normalize
label_desc: Use image node_id 3 for calling a global function with example usage: build_clip_model(pretrained_model) and returns: model,  _transform