code: def _load_pretrained_checkpoint(checkpoint_path, *args, **kwargs):
      assert (
          os.path.splitext(checkpoint_path)[1]
          in ALLOWED_CHECKPOINT_EXTS
      ), f"Checkpoint must have extensions: {ALLOWED_CHECKPOINT_EXTS}"
  
      _hack_imports()
  
      with PathManager.open(checkpoint_path, "rb") as f:
          ckpt = torch.load(
              f, map_location=lambda storage, loc: storage
          )
      assert "config" in ckpt, (
          "No configs provided with pretrained model "
          " while checkpoint also doesn't have configuration."
      )
      config = ckpt.pop("config", None)
      model_config = config.get("model_config", config)
  
      ckpt = ckpt.get("model", ckpt)
  
      if "model_name" in kwargs:
          model_name = kwargs["model_name"]
      else:
          assert (
              len(model_config.keys()) == 1
          ), "Only one model type should be specified."
          model_name = list(model_config.keys())[0]
  
      model_config = model_config.get(model_name)
      return {
          "config": model_config,
          "checkpoint": ckpt,
          "full_config": config,
      }
  
imports: import glob
  import importlib
  import logging
  import os
  import sys
  import warnings
  from typing import Any, Dict
  import torch
  from mmf.common.registry import registry
  from mmf.utils.checkpoint_updater import get_pretrained_state_mapping_checkpoint
  from mmf.utils.configuration import get_mmf_env, load_yaml
  from mmf.utils.distributed import is_main, is_xla, open_if_main, synchronize
  from mmf.utils.download import download_pretrained_model
  from mmf.utils.file_io import PathManager
  from mmf.utils.general import get_current_device, updir
  from mmf.utils.xla import save_xla_ckpt
  from omegaconf import OmegaConf
label_desc: Use image node_id 5 for calling a global function with example usage: _load_pretrained_checkpoint(checkpoint_path) and returns: dict