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
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.
towhee/models/coformer/coformer.py