code: def add_self_loops(
      arcs: List[List[Any]], disambig_token: int, disambig_word: int
  ) -> List[List[Any]]:
      """Adds self-loops to states of an FST to propagate disambiguation symbols
      through it. They are added on each state with non-epsilon output symbols
      on at least one arc out of the state.
      See also fstaddselfloops.pl from Kaldi. One difference is that
      Kaldi uses OpenFst style FSTs and it has multiple final states.
      This function uses k2 style FSTs and it does not need to add self-loops
      to the final state.
      The input label of a self-loop is `disambig_token`, while the output
      label is `disambig_word`.
      Args:
        arcs:
          A list-of-list. The sublist contains
          `[src_state, dest_state, label, aux_label, score]`
        disambig_token:
          It is the token ID of the symbol `#0`.
        disambig_word:
          It is the word ID of the symbol `#0`.
      Return:
        Return new `arcs` containing self-loops.
      """
      states_needs_self_loops = set()
      for arc in arcs:
          src, dst, ilabel, olabel, score = arc
          if olabel != 0:
              states_needs_self_loops.add(src)
  
      ans = []
      for s in states_needs_self_loops:
          ans.append([s, s, disambig_token, disambig_word, 0])
  
      return arcs + ans
  
file_path: espnet/egs2/tedx_spanish_openslr67/asr1/pyscripts/k2/prepare_lang.py
imports: import argparse
  import math
  from collections import defaultdict
  from pathlib import Path
  from typing import Any, Dict, List, Tuple
  import k2
  import torch
  from icefall.lexicon import read_lexicon, write_lexicon
  from espnet2.utils.types import str2bool
label_desc: Use image node_id 7 for calling a global function with example usage: add_self_loops(arcs, disambig_token, disambig_word) and returns: unknown