code: def process_file_itn(
      inputname: str, out: TextIO, keys2replacements: Dict[str, str]
  ) -> None:
      """Processes one file in Google TN Dataset format to get the labeled data for ThutmoseTaggerModel
  
      Args:
          inputname: name of input file
          out: output stream
          keys2replacements: Mapping from (semiotic class, spoken, written) to the segmented written form,
           which is aligned one-to-one to spoken words (this is the result obtained from Giza++ alignment pipeline)
  
      """
      words = []
      tags = []
      semiotic_info = []
      sent_is_ok = True
      with open(inputname, "r", encoding="utf-8") as f:
          for line in f:
              if line.startswith("<eos>"):
                  if sent_is_ok and len(words) > 0:
                      out.write(
                          " ".join(words)
                          + "\t"
                          + " ".join(tags)
                          + "\t"
                          + ";".join(semiotic_info)
                          + "\n"
                      )
                  words = []
                  tags = []
                  semiotic_info = []
                  sent_is_ok = True
              else:
                  cls, written, spoken = line.strip().split("\t")
                  if spoken == "sil":
                      continue
                  if spoken == "<self>":
                      words.append(written.casefold())
                      tags.append("<SELF>")
                      continue
                  (
                      src,
                      dst,
                      same_begin,
                      same_end,
                  ) = get_src_and_dst_for_alignment(
                      cls.casefold(), written, spoken, args.lang
                  )
                  same_from_begin = (
                      [] if same_begin == "" else same_begin.split(" ")
                  )
                  same_from_end = (
                      [] if same_end == "" else same_end.split(" ")
                  )
                  key = cls.casefold() + "\t" + src + "\t" + dst
                  if key in keys2replacements:
                      replacements = keys2replacements[key].split(" ")
                      spoken_words = dst.split(" ")
                      for w, r in zip(
                          same_from_begin
                          + spoken_words
                          + same_from_end,
                          same_from_begin
                          + replacements
                          + same_from_end,
                      ):
                          words.append(w)
                          if cls == "LETTERS" or cls == "PLAIN":
                              if w == r:
                                  tags.append("<SELF>")
                              else:
                                  tags.append(r)
                          elif w == r.replace("_", ""):
                              tags.append("<SELF>")
                          else:
                              tags.append(r)
                      semiotic_info.append(
                          cls
                          + " "
                          + str(
                              len(words)
                              - len(spoken_words)
                              - len(same_from_begin)
                              - len(same_from_end)
                          )
                          + " "
                          + str(len(words))
                      )
                  else:
                      sent_is_ok = False
  
file_path: NeMo/examples/nlp/text_normalization_as_tagging/dataset_preparation/prepare_corpora_after_alignment.py
imports: import glob
  import os
  from argparse import ArgumentParser
  from collections import Counter
  from typing import Dict, Optional, TextIO, Tuple
  from nemo.collections.nlp.data.text_normalization_as_tagging.utils import get_src_and_dst_for_alignment
  from nemo.utils import logging
label_desc: Use image node_id 1 for calling a global function with example usage: process_file_itn(inputname, out, keys2replacements) without return types