code: def create_model(
      model_name: str = None,
      vidx_ridx: Any = None,
      device: str = None,
  ) -> CoFormer:
      """
      Create CoFormer model
      Args:
          model_name (`str`):
              CoFormer model name.
          vidx_ridx (`Any`):
              Verb index to role index.
          device (`str`):
              cuda or cpu.
  
      Returns:
          (`CoFormer`):
              CoFormer instance.
      """
      if device is None:
          device = "cuda" if torch.cuda.is_available() else "cpu"
      if model_name == "coformer":
          model_config = _C.MODEL.CoFormer
      else:
          raise AttributeError(f"Invalid model_name {model_name}.")
      backbone = build_backbone(
          hidden_dim=model_config.hidden_dim,
          position_embedding=model_config.position_embedding,
          backbone=model_config.backbone,
      )
      transformer = build_transformer(
          d_model=model_config.hidden_dim,
          dropout=model_config.dropout,
          nhead=model_config.nhead,
          num_glance_enc_layers=model_config.num_glance_enc_layers,
          num_gaze_s1_dec_layers=model_config.num_gaze_s1_dec_layers,
          num_gaze_s1_enc_layers=model_config.num_gaze_s1_enc_layers,
          num_gaze_s2_dec_layers=model_config.num_gaze_s2_dec_layers,
          dim_feedforward=model_config.dim_feedforward,
      )
      model = CoFormer(
          backbone,
          transformer,
          num_noun_classes=model_config.num_noun_classes,
          vidx_ridx=vidx_ridx,
      )
      model.to(device)
      return model
  
file_path: towhee/towhee/models/coformer/coformer.py
imports: import torch
  import torch.nn.functional
  from typing import Any
  from torch import nn
  from towhee.models.coformer.utils import nested_tensor_from_tensor_list
  from towhee.models.coformer.backbone import build_backbone
  from towhee.models.coformer.transformer import build_transformer
  from towhee.models.coformer.config import _C
label_desc: Use image node_id 1 for calling a global function with example usage: create_model(model_name, vidx_ridx, device) and returns: model