code: def prepare_text(lines_file_path, output_dir, split_ids):
      """Create 'text' file (map of ids to transcripts) in Kaldi format
  
      Parameters
      ----------
      lines_file_path : str
          The file path of the "lines.txt" label file of the IAM dataset
      output_dir : str
          The folder path for output, e.g. data/
      split_ids : list of str
          a list of ids to process, e.g. train/valid/test splits
  
      Returns
      -------
      skipped_ids : list of str
          a list of ids that were skipped,
          e.g. due to having an empty transcription
      """
      output_lines = []
      skipped_ids = []
      with open(lines_file_path) as lines_file:
          for line in lines_file.readlines():
              # skip comment lines
              if line[0] == "#":
                  continue
  
              line_split = line.strip().split()
  
              # extract line ID
              line_id = line_split[0]
  
              if line_id in split_ids:
                  # extract and format transcription into Kaldi style
                  transcription = " ".join(line_split[8:])
                  transcription = transcription.replace("|", " ")
                  transcription = transcription.strip()
  
                  if transcription == "":
                      print(
                          f"Line {line_id} has an empty transcript, skipping"
                      )
                      skipped_ids.append(line_id)
                      continue
  
                  output_lines.append(f"{line_id} {transcription}\n")
  
      output_lines.sort()
  
      with open(os.path.join(output_dir, "text"), "w") as out_file:
          out_file.writelines(output_lines)
  
      return skipped_ids
  
file_path: espnet/egs2/iam/ocr1/local/data_prep.py
imports: import argparse
  import os
  import numpy
  from PIL import Image
  from espnet.utils.cli_writers import file_writer_helper
label_desc: Use image node_id 1 for calling a global function with example usage: prepare_text(lines_file_path, output_dir, split_ids) and returns: skipped_ids