code: def normalize_words(
      target_words_batch, predicted_words_batch, glm_alternatives=None
  ):
      """
      Remove some references and hypotheses we don't want to score.
      We remove incomplete words (i.e. words that start with "-"),
      expand common contractions (e.g. I'v -> I have),
      and split linked words (e.g. pseudo-rebel -> pseudo rebel).
      Then we check if some of the predicted words have mapping rules according
      to the glm (alternatives) file.
      Finally, we check if a predicted word is on the exclusion list.
      The exclusion list contains stuff like "MM", "HM", "AH", "HUH", which would get mapped,
      into hesitations by the glm file anyway.
      The goal is to remove all the things that appear in the reference as optional/deletable
      (i.e. inside parentheses).
      If we delete these tokens, there is no loss,
      and if we recognize them correctly, there is no gain.
  
      The procedure is adapted from Kaldi's local/score.sh script.
  
      Parameters
      ----------
      glm_alternatives : dict
          Dictionary containing valid word alternatives
      target_words_batch : list
          List of length <batch_size> containing lists of target words for each utterance
      predicted_words_batch : list of list
          List of length <batch_size> containing lists of predicted words for each utterance
  
      Returns
      -------
  
      A new list containing the filtered predicted words.
  
      """
      excluded_words = [
          "<UNK>",
          "UH",
          "UM",
          "EH",
          "MM",
          "HM",
          "AH",
          "HUH",
          "HA",
          "ER",
          "OOF",
          "HEE",
          "ACH",
          "EEE",
          "EW",
      ]
  
      target_words_batch = expand_contractions_batch(target_words_batch)
      predicted_words_batch = expand_contractions_batch(
          predicted_words_batch
      )
  
      # Find all possible alternatives for each word in the target utterance
      alternative2tgt_word_batch = []
      for tgt_utterance in target_words_batch:
          alternative2tgt_word = defaultdict(str)
          if glm_alternatives is not None:
              for tgt_wrd in tgt_utterance:
                  alts = glm_alternatives[tgt_wrd]
                  for alt in alts:
                      if alt != tgt_wrd and len(alt) > 0:
                          alternative2tgt_word[alt] = tgt_wrd
          alternative2tgt_word_batch.append(alternative2tgt_word)
  
      # See if a predicted word is on the exclusion list,
      # and if it matches one of the valid alternatives.
      # Also do some cleaning.
      checked_predicted_words_batch = []
      for i, pred_utterance in enumerate(predicted_words_batch):
          alternative2tgt_word = alternative2tgt_word_batch[i]
          checked_predicted_words = []
          for pred_wrd in pred_utterance:
              # Remove stuff like [LAUGHTER]
              pred_wrd = re.sub(r"\[.*?\]", "", pred_wrd)
              # Remove any remaining punctuation
              pred_wrd = pred_wrd.translate(
                  str.maketrans("", "", string.punctuation)
              )
              # Sometimes things like LAUGHTER get appended to existing words e.g. THOUGHLAUGHTER
              if pred_wrd != "LAUGHTER" and pred_wrd.endswith(
                  "LAUGHTER"
              ):
                  pred_wrd = pred_wrd.replace("LAUGHTER", "")
              if pred_wrd != "NOISE" and pred_wrd.endswith("NOISE"):
                  pred_wrd = pred_wrd.replace("NOISE", "")
              if pred_wrd.endswith("VOCALIZED"):
                  pred_wrd = pred_wrd.replace("VOCALIZED", "")
              # Check word exclusion list
              if pred_wrd in excluded_words:
                  continue
              # Finally, check word alternatives
              tgt_wrd = alternative2tgt_word[pred_wrd]
              if len(tgt_wrd) > 0:
                  pred_wrd = tgt_wrd
              if len(pred_wrd) > 0:
                  checked_predicted_words.append(pred_wrd)
          checked_predicted_words_batch.append(checked_predicted_words)
      return target_words_batch, checked_predicted_words_batch
  
file_path: speechbrain/recipes/Switchboard/ASR/transformer/normalize_util.py
imports: import re
  import os
  import csv
  import string
  from collections import defaultdict
label_desc: Use image node_id 4 for calling a global function with example usage: normalize_words(target_words_batch, predicted_words_batch, glm_alternatives) and returns: target_words_batch,  checked_predicted_words_batch