code: def get_base_model(trainer, cfg):
      """
      Returns the base model to be fine-tuned.
      Currently supports two types of initializations:
      1) `init_from_nemo_model`, and
      2) `init_from_pretrained_model`.
      Args:
          trainer: PyTorch Lightning Trainer
          cfg: config
      Returns:
          asr_model: ASRModel instance
      """
      asr_model = None
      nemo_model_path = cfg.get("init_from_nemo_model", None)
      pretrained_name = cfg.get("init_from_pretrained_model", None)
      if nemo_model_path is not None and pretrained_name is not None:
          raise ValueError(
              "Only pass `init_from_nemo_model` or `init_from_pretrained_model` but not both"
          )
      elif nemo_model_path is None and pretrained_name is None:
          raise ValueError(
              "Both `init_from_nemo_model` and `init_from_pretrained_model cannot be None, should pass atleast one of them"
          )
      elif nemo_model_path is not None:
          asr_model = ASRModel.restore_from(
              restore_path=nemo_model_path
          )
      elif pretrained_name is not None:
          # Due to potential first time download of the model on the cluster, we need to make sure that only one
          # rank downloads the model and the others wait for the download to finish.
          num_ranks = trainer.num_devices * trainer.num_devices
  
          if num_ranks > 1 and is_global_rank_zero():
              asr_model = ASRModel.from_pretrained(
                  model_name=pretrained_name
              )
          else:
              # Sleep on all ranks for at least 60 seconds
              wait_time = int(
                  cfg.get("exp_manager", {}).get("seconds_to_sleep", 60)
              )
              if wait_time < 60:
                  wait_time = 60
  
              logging.info(
                  f"Sleeping for at least {wait_time} seconds to wait for model download to finish."
              )
  
              time.sleep(wait_time)
  
              # restore model from cached model dir
              asr_model = ASRModel.from_pretrained(
                  model_name=pretrained_name
              )
  
      return asr_model
  
file_path: NeMo/examples/asr/speech_to_text_finetune.py
imports: import time
  import pytorch_lightning
  from omegaconf import OmegaConf
  from nemo.collections.asr.models import ASRModel
  from nemo.core.config import hydra_runner
  from nemo.utils import logging, model_utils
  from nemo.utils.exp_manager import exp_manager
  from nemo.utils.get_rank import is_global_rank_zero
label_desc: Use image node_id 1 for calling a global function with example usage: get_base_model(trainer, cfg) and returns: asr_model