code: def compute_error_rate(hyp_wrd_path, ref_wrd_path, unit="word"):
      """each line is "<text> (None-<index>)" """
      tokenize_line = {
          "word": lambda x: re.sub(r" \(.*\)$", "", x.rstrip()).split(),
          "char": lambda x: list(re.sub(r" \(.*\)$", "", x.rstrip())),
      }.get(unit)
      if tokenize_line is None:
          raise ValueError(f"{unit} not supported")
  
      inds = [
          int(re.sub(r"\D*(\d*)\D*", r"\1", line))
          for line in open(hyp_wrd_path)
      ]
      hyps = [tokenize_line(line) for line in open(hyp_wrd_path)]
      refs = [tokenize_line(line) for line in open(ref_wrd_path)]
      assert len(hyps) == len(refs)
      err_rates = [
          editdistance.eval(hyp, ref) / len(ref)
          for hyp, ref in zip(hyps, refs)
      ]
      ind_to_err_rates = {i: e for i, e in zip(inds, err_rates)}
      return ind_to_err_rates
  
file_path: fairseq/examples/speech_synthesis/evaluation/eval_asr.py
imports: import argparse
  import editdistance
  import re
  import shutil
  import soundfile
  import subprocess
  from pathlib import Path
  from examples.speech_to_text.data_utils import load_tsv_to_dicts
label_desc: Use image node_id 4 for calling a global function with example usage: compute_error_rate(hyp_wrd_path, ref_wrd_path, unit) and returns: ind_to_err_rates