class_docstr: Word metrics for text recognition task.
  
  Args:
      mode (str or list[str]): Options are:
          - 'exact': Accuracy at word level.
          - 'ignore_case': Accuracy at word level, ignoring letter
            case.
          - 'ignore_case_symbol': Accuracy at word level, ignoring
            letter case and symbol. (Default metric for academic evaluation)
          If mode is a list, then metrics in mode will be calculated
          separately. Defaults to 'ignore_case_symbol'
      valid_symbol (str): Valid characters. Defaults to
          '[^A-Z^a-z^0-9^一-龥]'
      collect_device (str): Device name used for collecting results from
          different ranks during distributed training. Must be 'cpu' or
          'gpu'. Defaults to 'cpu'.
      prefix (str, optional): The prefix that will be added in the metric
          names to disambiguate homonymous metrics of different evaluators.
          If prefix is not provided in the argument, self.default_prefix
          will be used instead. Defaults to None.
docstr: Compute the metrics from processed results.
  
  Args:
      results (list[Dict]): The processed results of each batch.
  
  Returns:
      Dict: The computed metrics. The keys are the names of the metrics,
      and the values are corresponding results.
docstr_tok: ["Compute","the","metrics","from","processed","results",".","Args",":","results","(","list","[","Dict","]",")",":","The","processed","results","of","each","batch",".","Returns",":","Dict",":","The","computed","metrics",".","The","keys","are","the","names","of","the","metrics",",","and","the","values","are","corresponding","results","."]
code: def compute_metrics(self, results: Sequence[Dict]) -> Dict:
      """Compute the metrics from processed results.
  
      Args:
          results (list[Dict]): The processed results of each batch.
  
      Returns:
          Dict: The computed metrics. The keys are the names of the metrics,
          and the values are corresponding results.
      """
  
      eps = 1e-8
      eval_res = {}
      gt_word_num = len(results)
      if "exact" in self.mode:
          match_nums = [result["match_num"] for result in results]
          match_nums = sum(match_nums)
          eval_res["word_acc"] = 1.0 * match_nums / (eps + gt_word_num)
      if "ignore_case" in self.mode:
          match_ignore_case_num = [
              result["match_ignore_case_num"] for result in results
          ]
          match_ignore_case_num = sum(match_ignore_case_num)
          eval_res["word_acc_ignore_case"] = (
              1.0 * match_ignore_case_num / (eps + gt_word_num)
          )
      if "ignore_case_symbol" in self.mode:
          match_ignore_case_symbol_num = [
              result["match_ignore_case_symbol_num"]
              for result in results
          ]
          match_ignore_case_symbol_num = sum(
              match_ignore_case_symbol_num
          )
          eval_res["word_acc_ignore_case_symbol"] = (
              1.0 * match_ignore_case_symbol_num / (eps + gt_word_num)
          )
  
      for key, value in eval_res.items():
          eval_res[key] = float(f"{value:.4f}")
      return eval_res
  
imports: import re
  from difflib import SequenceMatcher
  from typing import Dict, Optional, Sequence, Union
  import mmengine
  from mmengine.evaluator import BaseMetric
  from rapidfuzz.distance import Levenshtein
  from mmocr.registry import METRICS
label_desc: Use image node_id 3 for calling the WordMetric obj's underlying member method code with example usage: obj.compute_metrics(results) and returns: eval_res