code: def get_mcore_model_from_nemo_file(
      nemo_restore_from_path, cpu_only=False
  ):
      model_cfg = MegatronGPTModel.restore_from(
          nemo_restore_from_path, return_config=True
      )
      model_cfg.tokenizer.vocab_file = None
      model_cfg.tokenizer.merge_file = None
      model_cfg.mcore_gpt = True
      model_cfg.use_cpu_initialization = cpu_only
  
      logging.info(
          "*** initializing mcore model with the following config"
      )
      logging.info(OmegaConf.to_yaml(model_cfg))
      trainer = Trainer(
          devices=1, accelerator="cpu", strategy=NLPDDPStrategy()
      )
  
      app_state = AppState()
      if os.path.isdir(nemo_restore_from_path):
          app_state.nemo_file_folder = nemo_restore_from_path
      else:
          logging.warning(
              "⚠️ `nemo_file_folder` is NOT set because checkpoint is not pre-extracted. Subsequent operations may fail."
          )
      mcore_model = MegatronGPTModel(model_cfg, trainer=trainer)
      return mcore_model
  
file_path: NeMo/scripts/nlp_language_modeling/convert_nemo_gpt_to_mcore.py
imports: import os
  from argparse import ArgumentParser
  from collections import OrderedDict
  import torch
  from omegaconf import OmegaConf, open_dict
  from pytorch_lightning.trainer.trainer import Trainer
  from nemo.collections.nlp.models.language_modeling.megatron_gpt_model import MegatronGPTModel
  from nemo.collections.nlp.parts.nlp_overrides import NLPDDPStrategy
  from nemo.utils import AppState, logging
label_desc: Use image node_id 2 for calling a global function with example usage: get_mcore_model_from_nemo_file(nemo_restore_from_path, cpu_only) and returns: mcore_model