code: def wer_summary(details_by_utterance):
      """
      Computes summary stats from the output of details_by_utterance
  
      Summary stats like WER
  
      Arguments
      ---------
      details_by_utterance : list
          See the output of wer_details_by_utterance
  
      Returns
      -------
      dict
          Dictionary with keys:
  
          * "WER": (float) Word Error Rate.
          * "SER": (float) Sentence Error Rate (percentage of utterances
            which had at least one error).
          * "num_edits": (int) Total number of edits.
          * "num_scored_tokens": (int) Total number of tokens in scored
            reference utterances (a missing hypothesis might still
            have been scored with 'all' scoring mode).
          * "num_erraneous_sents": (int) Total number of utterances
            which had at least one error.
          * "num_scored_sents": (int) Total number of utterances
            which were scored.
          * "num_absent_sents": (int) Hypotheses which were not found.
          * "num_ref_sents": (int) Number of all reference utterances.
          * "insertions": (int) Total number of insertions.
          * "deletions": (int) Total number of deletions.
          * "substitutions": (int) Total number of substitutions.
  
          NOTE: Some cases lead to ambiguity over number of
          insertions, deletions and substitutions. We
          aim to replicate Kaldi compute_wer numbers.
      """
      # Build the summary details:
      ins = dels = subs = 0
      num_scored_tokens = (
          num_scored_sents
      ) = (
          num_edits
      ) = num_erraneous_sents = num_absent_sents = num_ref_sents = 0
      for dets in details_by_utterance:
          num_ref_sents += 1
          if dets["scored"]:
              num_scored_sents += 1
              num_scored_tokens += dets["num_ref_tokens"]
              ins += dets["insertions"]
              dels += dets["deletions"]
              subs += dets["substitutions"]
              num_edits += dets["num_edits"]
              if dets["num_edits"] > 0:
                  num_erraneous_sents += 1
          if dets["hyp_absent"]:
              num_absent_sents += 1
      if num_scored_tokens != 0:
          WER = 100.0 * num_edits / num_scored_tokens
      else:
          WER = 0.0
      wer_details = {
          "WER": WER,
          "SER": 100.0 * num_erraneous_sents / num_scored_sents,
          "num_edits": num_edits,
          "num_scored_tokens": num_scored_tokens,
          "num_erraneous_sents": num_erraneous_sents,
          "num_scored_sents": num_scored_sents,
          "num_absent_sents": num_absent_sents,
          "num_ref_sents": num_ref_sents,
          "insertions": ins,
          "deletions": dels,
          "substitutions": subs,
      }
      return wer_details
  
file_path: speechbrain/speechbrain/utils/edit_distance.py
imports: import collections
label_desc: Use image node_id 9 for calling a global function with example usage: wer_summary(details_by_utterance) and returns: wer_details