code: def dump_seg_data(data, out_prefix):
      key_targs = {
          "codes": f"{out_prefix}.code.npy",
          "duration": f"{out_prefix}.dur.npy",
          "f0": f"{out_prefix}.f0.npy",
      }
      for key, targ in key_targs.items():
          assert not os.path.exists(targ)
          npaa = NpyAppendArray(targ)
          for utt_data in tqdm(data[key], desc=f"dumping {key}"):
              npaa.append(utt_data.numpy())
  
      assert not os.path.exists(f"{out_prefix}.path.txt")
      with open(f"{out_prefix}.path.txt", "w") as f:
          for x in data["path"]:
              f.write(f"{str(x)}\n")
  
      assert not os.path.exists(f"{out_prefix}.leng.txt")
      with open(f"{out_prefix}.leng.txt", "w") as f:
          for x in data["codes"]:
              f.write(f"{len(x)}\n")
  
      assert not os.path.exists(f"{out_prefix}.speaker.txt")
      with open(f"{out_prefix}.speaker.txt", "w") as f:
          for x in data["speaker"]:
              f.write(f"{str(x)}\n")
  
      print(f"wrote to files with prefix {out_prefix}")
  
file_path: fairseq/examples/textless_nlp/pgslm/prepare_dataset.py
imports: from multiprocessing import Pool
  import os
  from collections import defaultdict
  from itertools import starmap
  import torch
  from npy_append_array import NpyAppendArray
  from tqdm import tqdm
  from data_utils import dump_speaker_f0_stat, F0Stat, load_f0
  from fairseq.data.codedataset import ExpressiveCodeDataConfig, parse_manifest, F0_FRAME_SPACE, align_f0_to_durations
  from fairseq.tasks.speech_ulm_task import UnitDictionary
label_desc: Use image node_id 5 for calling a global function with example usage: dump_seg_data(data, out_prefix) without return types