code: def prepare_subcorpora_from_data() -> None:
      """Preprocess a corpus in Google TN Dataset format, extract TN-ITN phrase pairs, prepare input for GIZA++ alignment."""
      semiotic_vcb = Counter()
      cache_vcb = {}
      filenames = []
      for fn in listdir(args.data_dir + "/train"):
          filenames.append(args.data_dir + "/train/" + fn)
      for fn in listdir(args.data_dir + "/dev"):
          filenames.append(args.data_dir + "/dev/" + fn)
      for fn in filenames:
          with open(fn, "r", encoding="utf-8") as f:
              # Loop through each line of the file
              for line in f:
                  parts = line.strip().split("\t")
                  if len(parts) < 3:
                      continue
                  if len(parts) != 3:
                      raise ValueError(
                          "Expect 3 parts, got " + str(len(parts))
                      )
                  semiotic_class, written, spoken = (
                      parts[0],
                      parts[1].strip(),
                      parts[2].strip(),
                  )
                  if spoken == "<self>":
                      continue
                  semiotic_class = semiotic_class.casefold()
                  semiotic_vcb[semiotic_class] += 1
                  classdir = join(args.out_dir, semiotic_class)
                  if not isdir(classdir):
                      mkdir(classdir)
                  src, dst, _, _ = get_src_and_dst_for_alignment(
                      semiotic_class, written, spoken, args.lang
                  )
                  if src == "" or dst == "":
                      continue
                  if len(src.split(" ")) >= 100:
                      continue
                  if semiotic_class not in cache_vcb:
                      cache_vcb[semiotic_class] = Counter()
                  cache_vcb[semiotic_class][(src, dst)] += 1
      for sem in semiotic_vcb:
          classdir = join(args.out_dir, sem)
          if not isdir(classdir):
              raise ValueError("No such directory: " + classdir)
          print(classdir, " has ", semiotic_vcb[sem], " instances")
          with open(join(classdir, "run.sh"), "w") as out:
              out.write('GIZA_PATH="' + args.giza_dir + '"\n')
              out.write('MKCLS="' + args.mckls_binary + '"\n')
              out.write("\n")
              out.write("${GIZA_PATH}/plain2snt.out src dst\n")
              out.write(
                  "${MKCLS} -m2 -psrc -c15 -Vsrc.classes opt >& mkcls1.log\n"
              )
              out.write(
                  "${MKCLS} -m2 -pdst -c15 -Vdst.classes opt >& mkcls2.log\n"
              )
              out.write(
                  "${GIZA_PATH}/snt2cooc.out src.vcb dst.vcb src_dst.snt > src_dst.cooc\n"
              )
              out.write(
                  "${GIZA_PATH}/GIZA++ -S src.vcb -T dst.vcb -C src_dst.snt -coocurrencefile src_dst.cooc -p0 0.98 -o GIZA++ >& GIZA++.log\n"
              )
              out.write("##reverse direction\n")
              out.write(
                  "${GIZA_PATH}/snt2cooc.out dst.vcb src.vcb dst_src.snt > dst_src.cooc\n"
              )
              out.write(
                  "${GIZA_PATH}/GIZA++ -S dst.vcb -T src.vcb -C dst_src.snt -coocurrencefile dst_src.cooc -p0 0.98 -o GIZA++reverse >& GIZA++reverse.log\n"
              )
          out_src = open(join(classdir, "src"), "w", encoding="utf-8")
          out_dst = open(join(classdir, "dst"), "w", encoding="utf-8")
          out_freq = open(join(classdir, "freq"), "w", encoding="utf-8")
          for src, dst in cache_vcb[sem]:
              freq = cache_vcb[sem][(src, dst)]
              out_src.write(src + "\n")
              out_dst.write(dst + "\n")
              out_freq.write(str(freq) + "\n")
          out_freq.close()
          out_dst.close()
          out_src.close()
  
imports: from argparse import ArgumentParser
  from collections import Counter
  from os import listdir, mkdir
  from os.path import isdir, join
  from shutil import rmtree
  from nemo.collections.nlp.data.text_normalization_as_tagging.utils import get_src_and_dst_for_alignment
label_desc: Use image node_id 1 for calling a global function with example usage: prepare_subcorpora_from_data() without return types