code: def main(cfg: DictConfig) -> None:
      logging.debug(f"Config Params: {OmegaConf.to_yaml(cfg)}")
  
      if cfg.pretrained_model is None:
          raise ValueError("A pre-trained model should be provided.")
      _, model = instantiate_model_and_trainer(cfg, MODEL, False)
  
      if cfg.model.max_sequence_len != model.max_sequence_len:
          model.max_sequence_len = cfg.model.max_sequence_len
          model.builder._max_seq_length = cfg.model.max_sequence_len
      input_filenames = []
      output_filenames = []
  
      if (
          "from_filelist" in cfg.inference
          and "output_folder" in cfg.inference
      ):
          filelist_file = cfg.inference.from_filelist
          output_folder = cfg.inference.output_folder
          with open(filelist_file, "r", encoding="utf-8") as f:
              for line in f:
                  path = line.strip()
                  input_filenames.append(path)
                  folder, name = os.path.split(path)
                  output_filenames.append(
                      os.path.join(output_folder, name)
                  )
      else:
          text_file = cfg.inference.from_file
          logging.info(f"Running inference on {text_file}...")
          if not os.path.exists(text_file):
              raise ValueError(f"{text_file} not found.")
          input_filenames.append(text_file)
          output_filenames.append(cfg.inference.out_file)
  
      dataloader_cfg = {
          "batch_size": cfg.inference.get("batch_size", 8),
          "num_workers": cfg.inference.get("num_workers", 4),
          "pin_memory": cfg.inference.get("num_workers", False),
      }
      for input_filename, output_filename in zip(
          input_filenames, output_filenames
      ):
          if not os.path.exists(input_filename):
              logging.info(f"Skip non-existing {input_filename}.")
              continue
          model.infer(dataloader_cfg, input_filename, output_filename)
          logging.info(f"Predictions saved to {output_filename}.")
  
imports: import os
  from helpers import MODEL, instantiate_model_and_trainer
  from omegaconf import DictConfig, OmegaConf
  from nemo.core.config import hydra_runner
  from nemo.utils import logging
label_desc: Use image node_id 1 for calling a global function with example usage: main(cfg) without return types