code: def alignment(table):
      """Get the edit distance alignment from an edit op table.
  
      Walks back an edit operations table, produced by calling ``table(a, b)``,
      and collects the edit distance alignment of a to b. The alignment
      shows which token in a corresponds to which token in b. Note that the
      alignment is monotonic, one-to-zero-or-one.
  
      Arguments
      ----------
      table : list
          Edit operations table from ``op_table(a, b)``.
  
      Returns
      -------
      list
          Schema: ``[(str <edit-op>, int-or-None <i>, int-or-None <j>),]``
          List of edit operations, and the corresponding indices to a and b.
          See the EDIT_SYMBOLS dict for the edit-ops.
          The i indexes a, j indexes b, and the indices can be None, which means
          aligning to nothing.
  
      Example
      -------
      >>> # table for a=[1,2,3], b=[1,2,4]:
      >>> table = [['I', 'I', 'I', 'I'],
      ...          ['D', '=', 'I', 'I'],
      ...          ['D', 'D', '=', 'I'],
      ...          ['D', 'D', 'D', 'S']]
      >>> print(alignment(table))
      [('=', 0, 0), ('=', 1, 1), ('S', 2, 2)]
      """
      # The alignment will be the size of the longer sequence.
      # form: [(op, a_index, b_index)], index is None when aligned to empty
      alignment = []
      # Now we'll walk back the table to get the alignment.
      i = len(table) - 1
      j = len(table[0]) - 1
      while not (i == 0 and j == 0):
          if i == 0:
              j -= 1
              alignment.insert(0, (EDIT_SYMBOLS["ins"], None, j))
          elif j == 0:
              i -= 1
              alignment.insert(0, (EDIT_SYMBOLS["del"], i, None))
          else:
              if table[i][j] == EDIT_SYMBOLS["ins"]:
                  j -= 1
                  alignment.insert(0, (EDIT_SYMBOLS["ins"], None, j))
              elif table[i][j] == EDIT_SYMBOLS["del"]:
                  i -= 1
                  alignment.insert(0, (EDIT_SYMBOLS["del"], i, None))
              elif table[i][j] == EDIT_SYMBOLS["sub"]:
                  i -= 1
                  j -= 1
                  alignment.insert(0, (EDIT_SYMBOLS["sub"], i, j))
              else:
                  i -= 1
                  j -= 1
                  alignment.insert(0, (EDIT_SYMBOLS["eq"], i, j))
      return alignment
  
file_path: speechbrain/speechbrain/utils/edit_distance.py
imports: import collections
label_desc: Use image node_id 4 for calling a global function with example usage: alignment(table) and returns: alignment