code: def convert_offline_dataset_to_nemo(
      dataset: Dataset,
      cfg: HFDatasetConversionConfig,
      basedir: str,
      manifest_filepath: str,
  ):
      """
      Converts a HF dataset to a audio-preprocessed Nemo dataset in Offline mode.
      Also writes out a nemo compatible manifest file.
  
      Args:
          dataset: Iterable HF Dataset.
          cfg: HFDatasetConvertionConfig.
          basedir: Base output directory.
          manifest_filepath: Filepath of manifest.
      """
      num_proc = cfg.num_proc
      if num_proc < 0:
          num_proc = max(1, os.cpu_count() // 2)
  
      dataset = dataset.map(
          build_map_dataset_to_nemo_func(cfg, basedir),
          num_proc=num_proc,
      )
      ds_iter = iter(dataset)
  
      with open(manifest_filepath, "w") as manifest_f:
          for idx, sample in enumerate(
              tqdm.tqdm(
                  ds_iter,
                  desc=f"Processing {cfg.path} (split : {cfg.split}):",
                  total=len(dataset),
                  unit=" samples",
              )
          ):
              # remove large components from sample
              del sample["audio"]
              if "file" in sample:
                  del sample["file"]
              manifest_f.write(
                  f"{json.dumps(sample, ensure_ascii=cfg.ensure_ascii)}\n"
              )
  
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 5 for calling a global function with example usage: convert_offline_dataset_to_nemo(dataset, cfg, basedir, manifest_filepath) without return types