code: def create_lexicon(
      cfg: KaldiInitializerConfig,
      fst_dir: Path,
      unique_label: str,
      in_units_file: Path,
      out_words_file: Path,
  ) -> (Path, Path):
      disambig_in_units_file = (
          fst_dir / f"kaldi_dict.{cfg.in_labels}_disambig.txt"
      )
      lexicon_file = fst_dir / f"kaldi_lexicon.{unique_label}.txt"
      disambig_lexicon_file = (
          fst_dir / f"kaldi_lexicon.{unique_label}_disambig.txt"
      )
      if (
          not lexicon_file.exists()
          or not disambig_lexicon_file.exists()
          or not disambig_in_units_file.exists()
      ):
          logger.info(
              f"Creating {lexicon_file} (in units file: {in_units_file})"
          )
  
          assert (
              cfg.wav2letter_lexicon is not None
              or cfg.in_labels == cfg.out_labels
          )
  
          if cfg.wav2letter_lexicon is not None:
              lm_words = set()
              with open(out_words_file, "r") as lm_dict_f:
                  for line in lm_dict_f:
                      lm_words.add(line.split()[0])
  
              num_skipped = 0
              total = 0
              with open(cfg.wav2letter_lexicon, "r") as w2l_lex_f, open(
                  lexicon_file, "w"
              ) as out_f:
                  for line in w2l_lex_f:
                      items = line.rstrip().split("\t")
                      assert len(items) == 2, items
                      if items[0] in lm_words:
                          print(items[0], items[1], file=out_f)
                      else:
                          num_skipped += 1
                          logger.debug(
                              f"Skipping word {items[0]} as it was not found in LM"
                          )
                      total += 1
              if num_skipped > 0:
                  logger.warning(
                      f"Skipped {num_skipped} out of {total} words as they were not found in LM"
                  )
          else:
              with open(in_units_file, "r") as in_f, open(
                  lexicon_file, "w"
              ) as out_f:
                  for line in in_f:
                      symb = line.split()[0]
                      if (
                          symb != "<eps>"
                          and symb != "<ctc_blank>"
                          and symb != "<SIL>"
                      ):
                          print(symb, symb, file=out_f)
  
          lex_disambig_path = (
              Path(cfg.kaldi_root)
              / "egs/wsj/s5/utils/add_lex_disambig.pl"
          )
          res = subprocess.run(
              [lex_disambig_path, lexicon_file, disambig_lexicon_file],
              check=True,
              capture_output=True,
          )
          ndisambig = int(res.stdout)
          disamib_path = (
              Path(cfg.kaldi_root) / "egs/wsj/s5/utils/add_disambig.pl"
          )
          res = subprocess.run(
              [
                  disamib_path,
                  "--include-zero",
                  in_units_file,
                  str(ndisambig),
              ],
              check=True,
              capture_output=True,
          )
          with open(disambig_in_units_file, "wb") as f:
              f.write(res.stdout)
  
      return disambig_lexicon_file, disambig_in_units_file
  
imports: from dataclasses import dataclass
  import hydra
  from hydra.core.config_store import ConfigStore
  import logging
  from omegaconf import MISSING, OmegaConf
  import os
  import os.path
  from pathlib import Path
  import subprocess
  from typing import Optional
  from fairseq.data.dictionary import Dictionary
  from fairseq.dataclass import FairseqDataclass
label_desc: Use image node_id 2 for calling a global function with example usage: create_lexicon(cfg, fst_dir, unique_label, in_units_file, out_words_file) and returns: disambig_lexicon_file,  disambig_in_units_file