code: def build_shared_blank_topo(
      tokens: List[int], with_self_loops: bool = True
  ) -> "k2.Fsa":
      """Build the shared blank CTC topology.
      Zero is assumed to be the ID of the blank symbol.
      See https://github.com/k2-fsa/k2/issues/746#issuecomment-856421616
      """
      assert (
          -1 not in tokens
      ), "We assume -1 is ID of the final transition"
      assert 0 in tokens, "We assume 0 is the ID of the blank symbol"
  
      tokens = tokens.copy()
      tokens.remove(0)
      num_tokens = len(tokens)
      start = 0
      final = num_tokens + 1
      arcs = []
      arcs.append([start, start, 0, 0, 0])
      arcs.append([start, final, -1, -1, 0])
      arcs.append([final])
      for i, p in enumerate(tokens):
          i += 1
          arcs.append([start, start, p, p, 0])
          arcs.append([start, i, p, p, 0])
          arcs.append([i, start, p, 0, 0])
          if with_self_loops:
              arcs.append([i, i, p, 0, 0])
      arcs = sorted(arcs, key=lambda arc: arc[0])
      arcs = [[str(i) for i in arc] for arc in arcs]
      arcs = [" ".join(arc) for arc in arcs]
      arcs = "\n".join(arcs)
      ans = k2.Fsa.from_str(arcs, num_aux_labels=1)
      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 4 for calling a global function with example usage: build_shared_blank_topo(tokens, with__loops) and returns: ans