code: def build_topo(
      name: str,
      tokens: List[int],
      blank_num: int,
      with_self_loops: bool = True,
  ) -> "k2.Fsa":
      """Helper function to build a topology.
      It allows to build topologies with a non-zero blank ID.
      Args:
        name:
          The topology name. Choices: default, compact, shared_blank, minimal
        tokens:
          A list of tokens, e.g., phones, characters, etc.
        blank_num:
          Blank number. Must be in tokens
        with_self_loops:
          Whether to add token-to-epsilon self-loops to a topology
      Returns:
        Returns a topology FST.
      """
      if name == "default":
          ans = build_default_topo(tokens, with_self_loops)
      elif name == "compact":
          ans = build_compact_topo(tokens, with_self_loops)
      elif name == "shared_blank":
          ans = build_shared_blank_topo(tokens, with_self_loops)
      elif name == "minimal":
          ans = build_minimal_topo(tokens)
      else:
          raise ValueError(f"Unknown topo name: {name}")
      if blank_num != 0:
          labels = ans.labels
          blank_mask = labels == 0
          labels[(labels != -1) & (labels <= blank_num)] -= 1
          labels[blank_mask] = blank_num
          ans.labels = labels  # force update ans.labels property to notify FSA about modifications, required by k2
      ans = k2.arc_sort(ans)
      return ans
  
file_path: NeMo/nemo/collections/asr/parts/k2/topologies.py
imports: from functools import lru_cache
  from typing import List, Optional, Union
  import torch
  from nemo.core.utils.k2_guard import k2
label_desc: Use image node_id 1 for calling a global function with example usage: build_topo(name, tokens, blank_num, with__loops) and returns: ans