code: def main(args):
      roots = []
      if (
          not ONLY_LID
      ):  # TER will be parsed from trn and using sclite as the usual case
          for txt_path in glob.glob(
              f"{args.dir}/*/*/score_cer/result.txt"
          ):
              roots.append(os.path.dirname(txt_path))
          for txt_path in glob.glob(
              f"{args.dir}/*/*/score_wer/result.txt"
          ):
              roots.append(os.path.dirname(txt_path))
          for root in roots:
              print(f"Parsing TER results in {root}...")
              ref_trn_path = f"{root}/ref.trn"
              hyp_trn_path = f"{root}/hyp.trn"
  
              if args.score_type == "independent":
                  split_trn_by_rule(
                      root,
                      "independent",
                      independent_rule,
                      ref_trn_path,
                  )
                  split_trn_by_rule(
                      root,
                      "independent",
                      independent_rule,
                      hyp_trn_path,
                  )
              elif args.score_type == "normal":
                  split_trn_by_rule(
                      root, "few_shot", few_shot_rule, ref_trn_path
                  )
                  split_trn_by_rule(
                      root, "few_shot", few_shot_rule, hyp_trn_path
                  )
              elif args.score_type == "language_family":
                  split_trn_by_rule(
                      root,
                      "language_family",
                      language_family_rule,
                      ref_trn_path,
                  )
                  split_trn_by_rule(
                      root,
                      "language_family",
                      language_family_rule,
                      hyp_trn_path,
                  )
              elif args.score_type == "all":
                  split_trn_by_rule(root, "all", no_rule, ref_trn_path)
                  split_trn_by_rule(root, "all", no_rule, hyp_trn_path)
  
      if (
          LID or ONLY_LID
      ):  # LID will be parsed from inferenced text file directly
          tasks = []
          for hyp_txt_path in glob.glob(f"{args.dir}/*/*/text"):
              root = os.path.dirname(hyp_txt_path)
              data_dirname = os.path.basename(root)
              ref_txt_path = f"data/{data_dirname}/text"
              tasks.append((root, ref_txt_path, hyp_txt_path))
          for root, ref_txt_path, hyp_txt_path in tasks:
              print(f"Parsing LID results in {root}...")
              root = f"{root}/score_lid"
              lid_trn_path = f"{root}/lid.trn"
  
              lid_info = lid_parse(ref_txt_path, hyp_txt_path)
              write_lines(lid_info, lid_trn_path)
  
              if args.score_type == "independent":
                  split_trn_by_rule(
                      root,
                      "independent",
                      independent_rule,
                      lid_trn_path,
                  )
              elif args.score_type == "normal":
                  split_trn_by_rule(
                      root, "few_shot", few_shot_rule, lid_trn_path
                  )
              elif args.score_type == "language_family":
                  split_trn_by_rule(
                      root,
                      "language_family",
                      language_family_rule,
                      lid_trn_path,
                  )
              elif args.score_type == "all":
                  split_trn_by_rule(root, "all", no_rule, lid_trn_path)
  
imports: import argparse
  import glob
  import json
  import os
  import re
  from typing import Callable, List
  from linguistic_tree import LanguageTree
  from espnet2.utils.types import str2bool
label_desc: Use image node_id 11 for calling a global function with example usage: main(args) without return types