code: def write_dataset(chunks, path):
      if isinstance(path, str):
          with open(path, "a+", encoding="utf-8") as f:
              for chunk_idx in tqdm(
                  range(len(chunks)),
                  desc="Chunk ",
                  total=len(chunks),
                  unit=" chunks",
              ):
                  for text in chunks[chunk_idx]:
                      line = " ".join(text)
                      f.write(f"{line}\n")
      else:  # write to stdin of KenLM
          for chunk_idx in range(len(chunks)):
              for text in chunks[chunk_idx]:
                  line = " ".join(text)
                  path.write((line + "\n").encode())
  
file_path: NeMo/scripts/asr_language_modeling/ngram_lm/kenlm_utils.py
imports: import gzip
  import json
  import os
  import numpy
  import torch
  from joblib import Parallel, delayed
  from tqdm.auto import tqdm
  import nemo.collections.asr
  from nemo.collections.asr.parts.submodules.ctc_beam_decoding import DEFAULT_TOKEN_OFFSET
  from nemo.utils import logging
label_desc: Use image node_id 8 for calling a global function with example usage: write_dataset(chunks, path) without return types