code: def modify_pretrained_cfg(pretrained_cfg, trainer, cfg):
      with open_dict(pretrained_cfg):
          OmegaConf.set_struct(pretrained_cfg, True)
          pretrained_cfg.sequence_parallel = False
          pretrained_cfg.activations_checkpoint_granularity = None
          pretrained_cfg.activations_checkpoint_method = None
          pretrained_cfg.precision = trainer.precision
          if cfg.micro_batch_size is not None:
              pretrained_cfg.micro_batch_size = cfg.micro_batch_size
          if cfg.global_batch_size is not None:
              pretrained_cfg.global_batch_size = cfg.global_batch_size
          if trainer.precision == "16":
              pretrained_cfg.megatron_amp_O2 = False
      return pretrained_cfg
  
file_path: NeMo/examples/nlp/language_modeling/megatron_gpt_validate.py
imports: import os
  import tempfile
  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.modules.common.megatron.megatron_init import fake_initialize_model_parallel
  from nemo.collections.nlp.parts.nlp_overrides import MegatronHalfPrecisionPlugin, NLPDDPStrategy, NLPSaveRestoreConnector, PipelineMixedPrecisionPlugin
  from nemo.core.config import hydra_runner
  from nemo.utils import logging
  from nemo.utils.app_state import AppState
  from nemo.utils.model_utils import inject_model_parallel_rank
label_desc: Use image node_id 1 for calling a global function with example usage: modify_pretrained_cfg(pretrained_cfg, trainer, cfg) and returns: pretrained_cfg