code: def load_config_and_state_from_nemo(nemo_path):
      if torch.cuda.is_available():
          map_location = torch.device("cuda")
      else:
          map_location = torch.device("cpu")
      save_restore_connector = NLPSaveRestoreConnector()
      cwd = os.getcwd()
  
      with tempfile.TemporaryDirectory() as tmpdir:
          try:
              save_restore_connector._unpack_nemo_file(
                  path2file=nemo_path, out_folder=tmpdir
              )
  
              # Change current working directory to
              os.chdir(tmpdir)
              config_yaml = os.path.join(
                  tmpdir, save_restore_connector.model_config_yaml
              )
              cfg = OmegaConf.load(config_yaml)
  
              model_weights = os.path.join(
                  tmpdir, save_restore_connector.model_weights_ckpt
              )
              state_dict = (
                  save_restore_connector._load_state_dict_from_disk(
                      model_weights, map_location=map_location
                  )
              )
          finally:
              os.chdir(cwd)
  
      return cfg, state_dict
  
file_path: NeMo/examples/multimodal/text_to_image/convert_hf_ckpt_to_nemo.py
imports: import os
  import tempfile
  from argparse import ArgumentParser
  import torch
  from lightning_fabric.utilities.cloud_io import _load
  from omegaconf import OmegaConf
  from pytorch_lightning.plugins.environments import TorchElasticEnvironment
  from pytorch_lightning.trainer.trainer import Trainer
  from nemo.collections.multimodal.models.text_to_image.controlnet.controlnet import MegatronControlNet
  from nemo.collections.multimodal.models.text_to_image.stable_diffusion.ldm.ddpm import MegatronLatentDiffusion
  from nemo.collections.nlp.parts.nlp_overrides import NLPSaveRestoreConnector
  from nemo.utils import AppState, logging
  from nemo.utils.distributed import initialize_distributed
label_desc: Use image node_id 2 for calling a global function with example usage: load_config_and_state_from_nemo(nemo_path) and returns: cfg,  state_dict