def create_model(
        clip_model: Union[str, nn.Module],
        pretrained: bool = False,
        jit: bool = False,
        device: str = None,
        checkpoints: dict = None,
        cfg: dict = None
) -> ActionClip:
    """
    Create action clip model
    Args:
        clip_model (`Union[str, nn.Module]`):
            A clip model name or a model instance.
        pretrained (`bool`):
            Whether model is pretrained.
        jit (`bool`):
            Whether returned one is a jit model, only useful when `pretrained` is True.
        device (`str`):
            Cuda or gpu.
        checkpoints (`dict`):
            Checkpoints state infos, only useful when `pretrained` is True.
        cfg (`dict`):
            Other model configs.

    Returns:
        (`ActionClip`)
            ActionClip model instance.
    """
    if device is None:
        device = "cuda" if torch.cuda.is_available() else "cpu"
    if isinstance(clip_model, str):
        configs = get_configs(model_name=clip_model)
        clip_model = clip.create_model(model_name=clip_model, pretrained=pretrained, jit=jit, device=device)
    else:
        configs = get_configs()
    if cfg is not None:
        configs.update(**cfg)
    visual_prompt_type = configs["visual_prompt_type"]
    num_frames = configs["num_frames"]
    visual_prompt = VisualPrompt(visual_prompt_type, clip_model.state_dict(), num_frames).to(device)
    if pretrained and checkpoints:
        if "clip_state_dict" in checkpoints:
            clip_state_dict = map_state_dict(checkpoints, "clip_state_dict")
            clip_model.load_state_dict(clip_state_dict)
        if "visual_state_dict" in checkpoints:
            visual_state_dict = map_state_dict(checkpoints, "visual_state_dict")
            visual_prompt.load_state_dict(visual_state_dict)
    model = ActionClip(clip_model=clip_model, visual_prompt=visual_prompt)
    return model
Create action clip model
Args:
clip_model (`Union[str, nn.Module]`):
A clip model name or a model instance.
pretrained (`bool`):
Whether model is pretrained.
jit (`bool`):
Whether returned one is a jit model, only useful when `pretrained` is True.
device (`str`):
Cuda or gpu.
checkpoints (`dict`):
Checkpoints state infos, only useful when `pretrained` is True.
cfg (`dict`):
Other model configs.

Returns:
(`ActionClip`)
ActionClip model instance.
towhee/models/action_clip/action_clip.py