code: def main(cfg: HFDatasetConversionConfig):
      # Convert dataclass to omegaconf
      if is_dataclass(cfg):
          cfg = OmegaConf.structured(cfg)
  
      # Prepare output subdirs
      prepare_output_dirs(cfg)
  
      # Load dataset in offline/streaming mode
      dataset = None
      try:
          dataset = load_dataset(
              path=cfg.path,
              name=cfg.name,
              split=cfg.split,
              cache_dir=None,
              streaming=cfg.streaming,
              token=cfg.use_auth_token,
          )
  
      except Exception as e:
          print(
              "HuggingFace datasets failed due to some reason (stack trace below). \nFor certain datasets (eg: MCV), "
              "it may be necessary to login to the huggingface-cli (via `huggingface-cli login`).\n"
              "Once logged in, you need to set `use_auth_token=True` when calling this script.\n\n"
              "Traceback error for reference :\n"
          )
          print(traceback.format_exc())
          exit(1)
  
      # Multiple datasets were provided at once, process them one by one into subdirs.
      if isinstance(dataset, dict):
          print()
          print(
              "Multiple splits found for dataset",
              cfg.path,
              ":",
              list(dataset.keys()),
          )
  
          keys = list(dataset.keys())
          for key in keys:
              ds_split = dataset[key]
              print(f"Processing split {key} for dataset {cfg.path}")
  
              cfg.split_output_dir = os.path.join(
                  cfg.resolved_output_dir, key
              )
              process_dataset(ds_split, cfg)
  
              del dataset[key], ds_split
  
          # reset the split output directory
          cfg.split_output_dir = None
  
      else:
          # Single dataset was found, process into resolved directory.
          print(
              "Single split found for dataset",
              cfg.path,
              "| Split chosen =",
              cfg.split,
          )
  
          if cfg.split is not None:
              cfg.split_output_dir = os.path.join(
                  cfg.resolved_output_dir, cfg.split
              )
  
          process_dataset(dataset, cfg)
  
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 8 for calling a global function with example usage: main(cfg) without return types