code: def create_model(
      module: nn.Module,
      configs,
      pretrained: bool = False,
      checkpoint_path: str = None,
      device: str = None,
  ):
      if device is None:
          device = "cuda" if torch.cuda.is_available() else "cpu"
  
      url = None
      if "url" in configs:
          url = configs["url"]
          del configs["url"]
  
      model = module(**configs).to(device)
      if pretrained:
          if checkpoint_path:
              local_path = checkpoint_path
          elif url:
              local_path = download_from_url(url=url)
          else:
              raise AttributeError(
                  "No url or checkpoint_path is provided for pretrained model."
              )
          state_dict = torch.load(local_path, map_location=device)
          if isinstance(state_dict, dict):
              if "model" in state_dict:
                  state_dict = state_dict["model"]
              model.load_state_dict(state_dict)
          else:
              model = state_dict
      model.eval()
      return model
  
imports: import torch
  from torch import nn
  from towhee.models.utils.download import download_from_url
label_desc: Use image node_id 1 for calling a global function with example usage: create_model(module, configs, pretrained, checkpoint_path, device) and returns: model