code: def process_dataset(
      dataset: IterableDataset, cfg: HFDatasetConversionConfig
  ):
      """
      Top level method that processes a given IterableDataset to Nemo compatible dataset.
      It also writes out a nemo compatible manifest file.
  
      Args:
          dataset: HF Dataset.
          cfg: HFDatasetConvertionConfig
      """
      dataset = dataset.cast_column(
          "audio", Audio(cfg.sampling_rate, mono=True)
      )
  
      # for Common Voice, "sentence" is used instead of "text" to store the transcript.
      if "sentence" in dataset.features:
          dataset = dataset.rename_column("sentence", "text")
  
      if cfg.split_output_dir is None:
          basedir = cfg.resolved_output_dir
          manifest_filename = (
              f"{cfg.path.replace('/', '_')}_manifest.json"
          )
      else:
          basedir = cfg.split_output_dir
          split = os.path.split(cfg.split_output_dir)[-1]
          manifest_filename = (
              f"{split}_{cfg.path.replace('/', '_')}_manifest.json"
          )
  
          if not os.path.exists(cfg.split_output_dir):
              os.makedirs(cfg.split_output_dir, exist_ok=True)
  
          cfg.split = split
  
      manifest_filepath = os.path.abspath(
          os.path.join(basedir, manifest_filename)
      )
  
      if cfg.streaming:
          convert_streaming_dataset_to_nemo(
              dataset,
              cfg,
              basedir=basedir,
              manifest_filepath=manifest_filepath,
          )
      else:
          convert_offline_dataset_to_nemo(
              dataset,
              cfg,
              basedir=basedir,
              manifest_filepath=manifest_filepath,
          )
  
      print()
      print("Dataset conversion finished !")
  
imports: import json
  import os
  import traceback
  from dataclasses import dataclass, is_dataclass
  from typing import Optional
  import hydra
  import librosa
  import soundfile
  import tqdm
  from datasets import Audio, Dataset, IterableDataset, load_dataset
  from hydra.conf import HydraConf, RunDir
  from hydra.core.config_store import ConfigStore
  from omegaconf import OmegaConf
label_desc: Use image node_id 7 for calling a global function with example usage: process_dataset(dataset, cfg) without return types