code: def get_norm_text(hyps, refs):
      # this implementation is modified from LevenshteinAlignment of the kaldi toolkit
      # - https://github.com/kaldi-asr/kaldi/blob/master/src/bin/align-text.cc
  
      # initialize variables
      hyp_norm, ref_norm = [], []
  
      # length of two sequences
      hlen, rlen = len(hyps), len(refs)
  
      # initialization
      # - this is very memory-inefficiently implemented using a vector of vectors
      scores = zeros((hlen + 1, rlen + 1))
      for r in range(0, rlen + 1):
          scores[0][r] = r
      for h in range(1, hlen + 1):
          scores[h][0] = scores[h - 1][0] + 1
          for r in range(1, rlen + 1):
              hyp_nosp, ref_nosp = norm_space(hyps[h - 1]), norm_space(
                  refs[r - 1]
              )
              sub_or_cor = scores[h - 1][r - 1] + get_score(
                  hyp_nosp, ref_nosp
              )
              insert, delete = (
                  scores[h - 1][r] + 1,
                  scores[h][r - 1] + 1,
              )
              scores[h][r] = min(sub_or_cor, insert, delete)
  
      # traceback and compute the alignment
      h, r = hlen, rlen  # start from the bottom
      while h > 0 or r > 0:
          if h == 0:
              last_h, last_r = h, r - 1
          elif r == 0:
              last_h, last_r = h - 1, r
          else:
              # get score
              hyp_nosp, ref_nosp = norm_space(hyps[h - 1]), norm_space(
                  refs[r - 1]
              )
              sub_or_cor = scores[h - 1][r - 1] + get_score(
                  hyp_nosp, ref_nosp
              )
              insert, delete = (
                  scores[h - 1][r] + 1,
                  scores[h][r - 1] + 1,
              )
  
              # choose sub_or_cor if all else equal
              if sub_or_cor <= min(insert, delete):
                  last_h = h - 1
                  last_r = r - 1
              else:
                  if insert < delete:
                      last_h = h - 1
                      last_r = r
                  else:
                      last_h = h
                      last_r = r - 1
  
          c_hyp = hyps[last_h] if last_h != h else ""
          c_ref = refs[last_r] if last_r != r else ""
          h, r = last_h, last_r
  
          # do word-spacing normalization
          if c_hyp != c_ref and norm_space(c_hyp) == norm_space(c_ref):
              c_hyp = c_ref
          if c_hyp != "":
              hyp_norm.append(c_hyp)
          if c_ref != "":
              ref_norm.append(c_ref)
  
      # reverse list
      hyp_norm.reverse()
      ref_norm.reverse()
  
      return (hyp_norm, ref_norm)
  
file_path: espnet/egs/ksponspeech/asr1/local/get_space_normalized_hyps.py
imports: import logging
  import os
  import sys
  import configargparse
  from numpy import zeros
label_desc: Use image node_id 4 for calling a global function with example usage: get_norm_text(hyps, refs) and returns: hyp_norm,  ref_norm