code: def add_self_loops(
      graph: "k2.Fsa", label: int = 0, mode: str = "auto"
  ):
      """Adds self-loops with given label to a graph.
      Supported modes are ``input``, ``output``, and ``auto``,
      Where ``input`` leaves aux_labels zeroes, if present, ``output`` leaves labels zeroes
      """
      assert mode in (
          "input",
          "output",
          "auto",
      ), "Supported modes are ``input``, ``output``, and ``auto``: {mode}"
      assert mode != "output" or hasattr(
          graph, "aux_labels"
      ), "Graph must have aux_labels for mode ``output``"
      new_graph, arc_map = k2.add_epsilon_self_loops(
          graph, ret_arc_map=True
      )
  
      if mode != "output":
          new_graph.labels[arc_map == -1] = label
      if mode != "input" and hasattr(graph, "aux_labels"):
          new_graph.aux_labels[arc_map == -1] = label
      return reset_properties_fsa(new_graph)
  
imports: import os
  import struct
  from pickle import UnpicklingError
  from typing import List, Optional, Tuple, Union
  import torch
  from nemo.core.utils.k2_guard import k2
  from nemo.utils import logging
label_desc: Use image node_id 13 for calling a global function with example usage: add_self_loops(graph, label, mode) and returns: reset_properties_fsa