code: def get_config_from_folder_or_ckpt(
      folder: str, ckpt: Dict[str, Any] = None
  ) -> Dict[str, Any]:
      r"""gets config from folder or checkpoint
  
      Args:
          folder (str): folder from which config will be searched first
          ckpt (Optional[Dict[str, Any]]): optional checkpoint from which config
              might be found.
  
      Returns:
          config (Dict[str, Any]): config object
      """
      configs = glob.glob(os.path.join(folder, "*.yaml"))
  
      if len(configs) > 0:
          assert len(configs) <= 1, (
              "Multiple yaml files with the pretrained model. "
              + "MMF doesn't know what to do."
          )
          config_file = configs[0]
          config = load_yaml(config_file)
      else:
          assert "config" in ckpt, (
              "No configs provided with pretrained model"
              " while checkpoint also doesn't have configuration."
          )
          config = ckpt["config"]
  
      return 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 4 for calling a global function with example usage: get_config_from_folder_or_ckpt(folder, ckpt) and returns: config