code: def model_from_checkpoint(
      filename: Union[Path, str],
      model_name=None,
      backbone_name=None,
      classes=None,
      is_coco=False,
      img_size=None,
      map_location=None,
      strict=False,
      revise_keys=[
          (r"^module\.", ""),
      ],
      eval_mode=True,
      logger=None,
  ):
      """load checkpoint through URL scheme path.
      Args:
          filename (str): checkpoint file name with given prefix
          map_location (str, optional): Same as :func:`torch.load`.
              Default: None
      Returns:
          dict or OrderedDict: The loaded checkpoint.
      """
  
      if isinstance(filename, Path):
          filename = str(filename)
  
      checkpoint = _load_checkpoint(
          filename=filename, map_location=map_location, logger=logger
      )
  
      if is_coco and classes:
          err_msg = "`is_coco` cannot be set to True if `classes` is passed and `not None`. `classes` has priority. `is_coco` will be ignored."
          if logger is not None:
              logger.warning(err_msg)
          else:
              print(err_msg)
  
      if classes is None:
          if is_coco:
              classes = CLASSES
          else:
              classes = checkpoint["meta"].get("classes", None)
  
      class_map = None
      if classes:
          class_map = ClassMap(classes)
          num_classes = len(class_map)
  
      if img_size is None:
          img_size = checkpoint["meta"].get("img_size", None)
  
      if model_name is None:
          model_name = checkpoint["meta"].get("model_name", None)
  
      model_type = None
      if model_name:
          model = model_name.split(".")
          # If model_name contains three or more components, the library and model are the second to last and last components, respectively (e.g. models.mmdet.retinanet)
          if len(model) >= 3:
              model_type = getattr(
                  getattr(models, model[-2]), model[-1]
              )
          # If model_name follows the default convention, the library and model are the first and second components, respectively (e.g. mmdet.retinanet)
          else:
              model_type = getattr(getattr(models, model[0]), model[1])
  
      if backbone_name is None:
          backbone_name = checkpoint["meta"].get("backbone_name", None)
      if model_type and backbone_name:
          backbone = getattr(model_type.backbones, backbone_name)
  
      extra_args = {}
      if img_size is None:
          img_size = checkpoint["meta"].get("img_size", None)
  
      models_with_img_size = ("yolov5", "efficientdet")
      # if 'efficientdet' in model_name:
      if (model_name) and (
          any(m in model_name for m in models_with_img_size)
      ):
          extra_args["img_size"] = img_size
  
      # Instantiate model
      if model_type and backbone:
          model = model_type.model(
              backbone=backbone(pretrained=False),
              num_classes=num_classes,
              **extra_args,
          )
      else:
          model = None
  
      # OrderedDict is a subclass of dict
      if not isinstance(checkpoint, dict):
          raise RuntimeError(
              f"No state_dict found in checkpoint file {filename}"
          )
      # get state_dict from checkpoint
      if "state_dict" in checkpoint:
          state_dict = checkpoint["state_dict"]
      else:
          state_dict = checkpoint
      # strip prefix of state_dict
      for p, r in revise_keys:
          state_dict = {
              re.sub(p, r, k): v for k, v in state_dict.items()
          }
  
      # load state_dict
      if model:
          load_state_dict(model, state_dict, strict, logger)
      if eval_mode:
          model.eval()
  
      checkpoint_and_model = {
          "model": model,
          "model_type": model_type,
          "backbone": backbone,
          "class_map": class_map,
          "img_size": img_size,
          "checkpoint": checkpoint,
      }
      return checkpoint_and_model
  
imports: from icevision.imports import *
  from icevision.core import *
  from icevision import models
  from mmcv.runner import load_checkpoint, save_checkpoint, _load_checkpoint, load_state_dict
label_desc: Use image node_id 2 for calling a global function with example usage: model_from_checkpoint(filename, model_name, backbone_name, classes, is_coco, img_size, map_location, strict, revise_keys, eval_mode, logger) and returns: checkpoint_and_model