code: def run_asr_inference(cfg: DictConfig) -> DictConfig:
      """
      Execute ASR inference based on input mode and parameters.
      """
      if (cfg.model_path and cfg.pretrained_name) or (
          not cfg.model_path and not cfg.pretrained_name
      ):
          raise ValueError(
              "Please specify either cfg.model_path or cfg.pretrained_name!"
          )
  
      if cfg.inference.decoder_type not in [None, "ctc", "rnnt"]:
          raise ValueError(
              "decoder_type could only be null, ctc or rnnt"
          )
  
      if cfg.inference.mode == "offline":
          cfg = run_offline_inference(cfg)
  
      elif cfg.inference.mode == "chunked":
          if (
              "total_buffer_in_secs" not in cfg.inference
              or "chunk_len_in_secs" not in cfg.inference
              or not cfg.inference.total_buffer_in_secs
              or not cfg.inference.chunk_len_in_secs
          ):
              raise ValueError(
                  f"Please specify both total_buffer_in_secs and chunk_len_in_secs for chunked inference"
              )
          cfg = run_chunked_inference(cfg)
  
      elif cfg.inference.mode == "offline_by_chunked":
          # When use Conformer to transcribe long audio sample, we could probably encounter CUDA out of memory issue.
          # Here we use offline_by_chunked mode to simulate offline mode for Conformer.
          # And we specify default total_buffer_in_secs=22 and chunk_len_in_secs=20 to avoid above problem.
          OmegaConf.set_struct(cfg, True)
          if (
              "total_buffer_in_secs" not in cfg.inference
              or not cfg.inference.total_buffer_in_secs
          ):
              with open_dict(cfg):
                  cfg.inference.total_buffer_in_secs = 22
                  logging.info(
                      f"Does not provide total_buffer_in_secs required by {cfg.inference.mode} mode. Using default value {cfg.inference.total_buffer_in_secs}"
                  )
          if (
              "chunk_len_in_secs" not in cfg.inference
              or not cfg.inference.chunk_len_in_secs
          ):
              with open_dict(cfg):
                  cfg.inference.chunk_len_in_secs = 20
                  logging.info(
                      f"Does not provide total_buffer_in_secs required by {cfg.inference.mode} mode. Using default value {cfg.inference.chunk_len_in_secs}"
                  )
          cfg = run_chunked_inference(cfg)
  
      else:
          raise ValueError(
              f"inference could only be offline or chunked, but got {cfg.inference.mode}"
          )
  
      return cfg
  
file_path: NeMo/tools/asr_evaluator/utils.py
imports: import json
  import subprocess
  import tempfile
  from pathlib import Path
  from typing import Tuple
  from omegaconf import DictConfig, OmegaConf, open_dict
  from nemo.utils import logging
label_desc: Use image node_id 1 for calling a global function with example usage: run_asr_inference(cfg) and returns: cfg