code: def run_chunked_inference(cfg: DictConfig) -> DictConfig:
      if "output_filename" not in cfg or not cfg.output_filename:
          if cfg.model_path:
              model_name = Path(cfg.model_path).stem
          else:
              model_name = cfg.pretrained_name
          dataset_name = Path(cfg.test_ds.manifest_filepath).stem
          mode_name = (
              cfg.inference.mode
              + "B"
              + str(cfg.inference.total_buffer_in_secs)
              + "C"
              + str(cfg.inference.chunk_len_in_secs)
          )
  
          OmegaConf.set_struct(cfg, True)
          with open_dict(cfg):
              cfg.output_filename = (
                  model_name
                  + "-"
                  + dataset_name
                  + "-"
                  + mode_name
                  + ".json"
              )
  
      script_path = (
          Path(__file__).parents[2]
          / "examples"
          / "asr"
          / "asr_chunked_inference"
          / "ctc"
          / "speech_to_text_buffered_infer_ctc.py"
      )
      use_rnnt_scrpit = False
      # hybrid model
      if (
          cfg.pretrained_name
          and "hybrid" in cfg.pretrained_name.lower()
      ) or (cfg.model_path and "hybrid" in cfg.model_path.lower()):
          if cfg.inference.decoder_type != "ctc":
              use_rnnt_scrpit = True
      # rnnt model
      elif (
          (
              cfg.pretrained_name
              and "rnnt" in cfg.pretrained_name.lower()
          )
          or (
              cfg.pretrained_name
              and "transducer" in cfg.pretrained_name.lower()
          )
          or (cfg.model_path and "rnnt" in cfg.model_path.lower())
          or (cfg.model_path and "transducer" in cfg.model_path.lower())
      ):
          if (
              cfg.inference.decoder_type
              and cfg.inference.decoder_type != "rnnt"
          ):
              raise ValueError(
                  f"rnnt models only support rnnt deocoding! Current decoder_type: {cfg.inference.decoder_type}! Change it to null or rnnt for rnnt models"
              )
          use_rnnt_scrpit = True
  
      # ctc model
      elif (
          cfg.pretrained_name and "ctc" in cfg.pretrained_name.lower()
      ) or (cfg.model_path and "ctc" in cfg.model_path.lower()):
          if (
              cfg.inference.decoder_type
              and cfg.inference.decoder_type != "ctc"
          ):
              raise ValueError(
                  f"ctc models only support ctc deocoding! Current decoder_type: {cfg.inference.decoder_type}! Change it to null or ctc for ctc models"
              )
      else:
          raise ValueError(
              "Please make sure your pretrained_name or model_path contains \n\
              'hybrid' for EncDecHybridRNNTCTCModel model, \n\
              'transducer/rnnt' for EncDecRNNTModel model  or \n\
              'ctc' for EncDecCTCModel."
          )
  
      if use_rnnt_scrpit:
          script_path = (
              Path(__file__).parents[2]
              / "examples"
              / "asr"
              / "asr_chunked_inference"
              / "rnnt"
              / "speech_to_text_buffered_infer_rnnt.py"
          )
  
      # If need to change other config such as decoding strategy, could either:
      # 1) change TranscriptionConfig on top of the executed scripts such as speech_to_text_buffered_infer_rnnt.py, or
      # 2) add command as "decoding.strategy=greedy_batch " to below script
  
      base_cmd = f"python {script_path} \
      calculate_wer=False \
      model_path={cfg.model_path} \
      pretrained_name={cfg.pretrained_name} \
      dataset_manifest={cfg.test_ds.manifest_filepath} \
      output_filename={cfg.output_filename} \
      random_seed={cfg.random_seed} \
      batch_size={cfg.test_ds.batch_size} \
      num_workers={cfg.test_ds.num_workers} \
      chunk_len_in_secs={cfg.inference.chunk_len_in_secs} \
      total_buffer_in_secs={cfg.inference.total_buffer_in_secs} \
      model_stride={cfg.inference.model_stride} "
  
      subprocess.run(
          base_cmd,
          shell=True,
          check=True,
      )
      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 2 for calling a global function with example usage: run_chunked_inference(cfg) and returns: cfg