code: def create_L(
      kaldi_root: Path,
      fst_dir: Path,
      unique_label: str,
      lexicon_file: Path,
      in_units_file: Path,
      out_words_file: Path,
  ) -> Path:
      lexicon_graph = fst_dir / f"L.{unique_label}.fst"
  
      if not lexicon_graph.exists():
          logger.info(
              f"Creating {lexicon_graph} (in units: {in_units_file})"
          )
          make_lex = kaldi_root / "egs/wsj/s5/utils/make_lexicon_fst.pl"
          fstcompile = kaldi_root / "tools/openfst-1.6.7/bin/fstcompile"
          fstaddselfloops = kaldi_root / "src/fstbin/fstaddselfloops"
          fstarcsort = kaldi_root / "tools/openfst-1.6.7/bin/fstarcsort"
  
          def write_disambig_symbol(file):
              with open(file, "r") as f:
                  for line in f:
                      items = line.rstrip().split()
                      if items[0] == "#0":
                          out_path = str(file) + "_disamig"
                          with open(out_path, "w") as out_f:
                              print(items[1], file=out_f)
                              return out_path
  
              return None
  
          in_disambig_sym = write_disambig_symbol(in_units_file)
          assert in_disambig_sym is not None
          out_disambig_sym = write_disambig_symbol(out_words_file)
          assert out_disambig_sym is not None
  
          try:
              with open(lexicon_graph, "wb") as out_f:
                  res = subprocess.run(
                      [make_lex, lexicon_file],
                      capture_output=True,
                      check=True,
                  )
                  assert len(res.stderr) == 0, res.stderr.decode(
                      "utf-8"
                  )
                  res = subprocess.run(
                      [
                          fstcompile,
                          f"--isymbols={in_units_file}",
                          f"--osymbols={out_words_file}",
                          "--keep_isymbols=false",
                          "--keep_osymbols=false",
                      ],
                      input=res.stdout,
                      capture_output=True,
                  )
                  assert len(res.stderr) == 0, res.stderr.decode(
                      "utf-8"
                  )
                  res = subprocess.run(
                      [
                          fstaddselfloops,
                          in_disambig_sym,
                          out_disambig_sym,
                      ],
                      input=res.stdout,
                      capture_output=True,
                      check=True,
                  )
                  res = subprocess.run(
                      [fstarcsort, "--sort_type=olabel"],
                      input=res.stdout,
                      capture_output=True,
                      check=True,
                  )
                  out_f.write(res.stdout)
          except subprocess.CalledProcessError as e:
              logger.error(
                  f"cmd: {e.cmd}, err: {e.stderr.decode('utf-8')}"
              )
              os.remove(lexicon_graph)
              raise
          except AssertionError:
              os.remove(lexicon_graph)
              raise
  
      return lexicon_graph
  
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 4 for calling a global function with example usage: create_L(kaldi_root, fst_dir, unique_label, lexicon_file, in_units_file, out_words_file) and returns: lexicon_graph, None, out_path