code: def infer_dataset_segments(batch):
      """
      Helper method to run in batch mode over a mapped Dataset.
  
      Infers the path of the subdirectories for the dataset, removing {extracted/HASH}.
  
      Returns:
          A cleaned list of path segments
      """
      segments = []
      segment, path = os.path.split(batch["audio"]["path"])
      segments.insert(0, path)
      while segment not in ("", os.path.sep):
          segment, path = os.path.split(segment)
          segments.insert(0, path)
  
      if "extracted" in segments:
          index_of_basedir = segments.index("extracted")
          segments = segments[
              (index_of_basedir + 1 + 1) :
          ]  # skip .../extracted/{hash}/
  
      return segments
  
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 2 for calling a global function with example usage: infer_dataset_segments(batch) and returns: segments