code: def word_error_rate(
      hypotheses: List[str], references: List[str], use_cer=False
  ) -> float:
      """
      Computes Average Word Error rate between two texts represented as
      corresponding lists of string.
  
      Hypotheses and references must have same length.
  
      Args:
          hypotheses (list): list of hypotheses
          references(list) : list of references
          use_cer (bool): set True to enable cer
  
      Returns:
          wer (float): average word error rate
      """
      scores = 0
      words = 0
      if len(hypotheses) != len(references):
          raise ValueError(
              "In word error rate calculation, hypotheses and reference"
              " lists must have the same number of elements. But I got:"
              "{0} and {1} correspondingly".format(
                  len(hypotheses), len(references)
              )
          )
      for h, r in zip(hypotheses, references):
          if use_cer:
              h_list = list(h)
              r_list = list(r)
          else:
              h_list = h.split()
              r_list = r.split()
          words += len(r_list)
          # May deprecate using editdistance in future release for here and rest of codebase
          # once we confirm jiwer is reliable.
          scores += editdistance.eval(h_list, r_list)
      if words != 0:
          wer = 1.0 * scores / words
      else:
          wer = float("inf")
      return wer
  
file_path: NeMo/nemo/collections/asr/metrics/wer.py
imports: from typing import List, Tuple, Union
  import editdistance
  import jiwer
  import torch
  from torchmetrics import Metric
  from nemo.collections.asr.parts.submodules.ctc_decoding import AbstractCTCDecoding
  from nemo.collections.asr.parts.submodules.rnnt_decoding import AbstractRNNTDecoding
  from nemo.utils import logging
label_desc: Use image node_id 2 for calling a global function with example usage: word_error_rate(hypotheses, references, use_cer) and returns: wer