code: def create_model(
      model_name: str = "uniformer_k400_s8",
      pretrained: bool = False,
      weights_path: str = None,
      device: str = None,
  ):
      if device is None:
          device = "cuda" if torch.cuda.is_available() else "cpu"
      if model_name == "uniformer_k400_s8":
          config = _C.MODEL.UniFormerS8
      elif model_name == "uniformer_k400_s16":
          config = _C.MODEL.UniFormerS16
      elif model_name == "uniformer_k400_b8":
          config = _C.MODEL.UniFormerB8
      elif model_name == "uniformer_k400_b16":
          config = _C.MODEL.UniFormerB16
      else:
          raise AttributeError(f"Invalid model_name {model_name}.")
  
      model = Uniformer(
          depth=config.depth,
          num_classes=config.num_classes,
          img_size=config.img_size,
          in_chans=config.in_chans,
          embed_dim=config.embed_dim,
          head_dim=config.head_dim,
          mlp_ratio=config.mlp_ratio,
          qkv_bias=config.qkv_bias,
          qk_scale=config.qk_scale,
          representation_size=config.representation_size,
          drop_rate=config.drop_rate,
          attn_drop_rate=config.attn_drop_rate,
          drop_path_rate=config.drop_path_rate,
          split=config.split,
          std=config.std,
          use_checkpoint=config.use_checkpoint,
          checkpoint_num=config.checkpoint_num,
      )
      if pretrained:
          model_checkpoint = torch.load(
              weights_path, map_location=device
          )
          if "model" in model_checkpoint:
              model_checkpoint = model_checkpoint["model"]
          elif "model_state" in model_checkpoint:
              model_checkpoint = model_checkpoint["model_state"]
          # pylint: disable=E1136
          state_dict_3d = model.state_dict()
          for k in model_checkpoint.keys():
              # pylint: disable=E1136
              if model_checkpoint[k].shape != state_dict_3d[k].shape:
                  if len(state_dict_3d[k].shape) <= 2:
                      continue
                  # pylint: disable=E1136
                  time_dim = state_dict_3d[k].shape[2]
                  model_checkpoint[k] = model.inflate_weight(
                      model_checkpoint[k], time_dim
                  )
  
          if (
              model.num_classes
              != model_checkpoint["head.weight"].shape[0]
          ):
              del model_checkpoint["head.weight"]
              del model_checkpoint["head.bias"]
          model.load_state_dict(model_checkpoint)
  
      model.to(device)
      return model
  
imports: from collections import OrderedDict
  import torch
  from torch import nn
  from torch.utils import checkpoint
  from functools import partial
  from towhee.models.utils.general_utils import to_2tuple
  from towhee.models.utils.weight_init import trunc_normal_
  from towhee.models.layers.droppath import DropPath
  from towhee.models.layers.mlp import Mlp
  from towhee.models.layers.attention import MultiHeadAttention
  from towhee.models.uniformer.config import _C
  import os
label_desc: Use image node_id 8 for calling a global function with example usage: create_model(model_name, pretrained, weights_path, device) and returns: model