code: def _load_pretrained_model(model_name_or_path, *args, **kwargs):
      if PathManager.exists(model_name_or_path):
          download_path = model_name_or_path
          model_name = model_name_or_path
      else:
          download_path = download_pretrained_model(
              model_name_or_path, *args, **kwargs
          )
          model_name = model_name_or_path
  
      _hack_imports()
  
      ckpt_path = get_ckpt_path_from_folder(download_path)
      ckpt = get_ckpt_from_path(ckpt_path)
  
      # If configs are not present, will ckpt provide the config?
      config = get_config_from_folder_or_ckpt(download_path, ckpt)
      model_config = config.get("model_config", config)
      ckpt = ckpt.get("model", ckpt)
  
      # Also handle the case of model_name is path
      if PathManager.exists(model_name):
          # This shouldn't happen
          assert (
              len(model_config.keys()) == 1
          ), "Checkpoint contains more than one model?"
          # Take first key
          model_config = model_config[list(model_config.keys())[0]]
      else:
          model_config = model_config.get(
              model_name.split(os.path.sep)[-1].split(".")[0]
          )
  
      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 6 for calling a global function with example usage: _load_pretrained_model(model_name_or_path) and returns: dict