code: def collect_data(
      data_dir: Union[Path, str], lang: str, split: str, prefix: str
  ) -> List[List[Utterance]]:
      """Collect utterances in each long talk."""
  
      data_dir = Path(data_dir)
      txt_dir = data_dir / f"en-{lang}" / "data" / split / "txt"
      wav_dir = data_dir / f"en-{lang}" / "data" / split / "wav"
  
      with open(txt_dir / f"{split}.yaml", "r") as fp:
          utts = yaml.safe_load(fp)
  
      with open(txt_dir / f"{split}.en", "r") as fp:
          src_text = [ln.strip() for ln in fp.readlines()]
  
      with open(txt_dir / f"{split}.{lang}", "r") as fp:
          tgt_text = [ln.strip() for ln in fp.readlines()]
  
      assert len(src_text) == len(tgt_text) and len(tgt_text) == len(
          utts
      )
  
      wav2utts = defaultdict(list)
      for utt, src, tgt in zip(utts, src_text, tgt_text):
          wav_name: str = utt["wav"]  # e.g.: 'ted_767.wav'
          wav_path = str((wav_dir / wav_name).resolve())
          wav_id = f"{prefix}_{wav_name.removesuffix('.wav')}"
          start_time = float(utt["offset"])
          end_time = start_time + float(utt["duration"])
  
          # NOTE(yifan): each utterance can be used in two tasks (asr, st)
          wav2utts[wav_name + ".asr"].append(
              Utterance(
                  utt_id=(
                      f"{wav_id}_{round(1000 * start_time):07d}"
                      f"_{round(1000 * end_time):07d}_asr"
                  ),
                  wav_id=wav_id,
                  wav_path=wav_path,
                  start_time=start_time,
                  end_time=end_time,
                  lang="<en>",
                  task="<asr>",
                  text=" ".join(src.split()),
                  asr_text=" ".join(src.split()),
              )
          )
          wav2utts[wav_name + f".st_{lang}"].append(
              Utterance(
                  utt_id=(
                      f"{wav_id}_{round(1000 * start_time):07d}"
                      f"_{round(1000 * end_time):07d}_st_{lang}"
                  ),
                  wav_id=wav_id,
                  wav_path=wav_path,
                  start_time=start_time,
                  end_time=end_time,
                  lang="<en>",
                  task=f"<st_{lang}>",
                  text=" ".join(tgt.split()),
                  asr_text=" ".join(src.split()),
              )
          )
  
      return list(wav2utts.values())
  
imports: from argparse import ArgumentParser
  from collections import defaultdict
  from pathlib import Path
  from typing import Dict, List, Optional, Tuple, Union
  import yaml
  from utils import SYMBOL_NA, SYMBOL_NOSPEECH, SYMBOLS_TIME, LongUtterance, Utterance, generate_long_utterances
label_desc: Use image node_id 1 for calling a global function with example usage: collect_data(data_dir, lang, split, prefix) and returns: list