code: def load_config(llama_config):
      nemo_config = OmegaConf.load(
          os.path.join(
              os.path.dirname(__file__),
              "../../examples/nlp/language_modeling/conf/megatron_llama_config.yaml",
          )
      ).model
  
      if llama_config.get("rope_theta", None):
          nemo_config["rotary_base"] = llama_config["rope_theta"]
      nemo_config.encoder_seq_length = llama_config[
          "max_position_embeddings"
      ]
      nemo_config.num_layers = int(llama_config["num_hidden_layers"])
      nemo_config.hidden_size = llama_config["hidden_size"]
      nemo_config.ffn_hidden_size = llama_config["intermediate_size"]
      nemo_config.num_attention_heads = llama_config[
          "num_attention_heads"
      ]
      nemo_config.max_position_embeddings = llama_config[
          "max_position_embeddings"
      ]
      nemo_config.init_method_std = llama_config["initializer_range"]
      nemo_config.layernorm_epsilon = llama_config["rms_norm_eps"]
      if "num_key_value_heads" in llama_config:
          nemo_config.num_query_groups = llama_config[
              "num_key_value_heads"
          ]
      nemo_config.use_cpu_initialization = True
      nemo_config.activation = "fast-swiglu"
      nemo_config.tokenizer.model = llama_config["tokenizer_model"]
      if llama_config["rope_scaling"] is not None:
          if llama_config["rope_scaling"]["type"] == "linear":
              nemo_config[
                  "seq_len_interpolation_factor"
              ] = llama_config["rope_scaling"]["factor"]
          else:
              raise ValueError(
                  "Only linear rope scaling type is supported now"
              )
      if llama_config["rope_theta"] is not None:
          nemo_config["rotary_base"] = llama_config["rope_theta"]
  
      base = 128
      while llama_config["vocab_size"] % base != 0:
          base //= 2
      nemo_config.make_vocab_size_divisible_by = base
  
      return nemo_config
  
file_path: NeMo/scripts/nlp_language_modeling/convert_hf_llama_to_nemo.py
imports: import os
  from argparse import ArgumentParser
  from collections import OrderedDict
  import torch
  from omegaconf import OmegaConf
  from pytorch_lightning.core.saving import _load_state
  from pytorch_lightning.trainer.trainer import Trainer
  from transformers import LlamaForCausalLM, LlamaTokenizer
  from nemo.collections.nlp.models.language_modeling.megatron_gpt_model import MegatronGPTModel
  from nemo.collections.nlp.parts.nlp_overrides import GradScaler, MegatronHalfPrecisionPlugin, NLPDDPStrategy, NLPSaveRestoreConnector, PipelineMixedPrecisionPlugin
  from nemo.collections.nlp.parts.utils_funcs import torch_dtype_from_precision
  from nemo.utils import logging
label_desc: Use image node_id 3 for calling a global function with example usage: load_config(llama_config) and returns: nemo_config