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.
code: def __init__(
      self,
      mode: Union[str, Sequence[str]] = "ignore_case_symbol",
      valid_symbol: str = "[^A-Z^a-z^0-9^\u4e00-\u9fa5]",
      collect_device: str = "cpu",
      prefix: Optional[str] = None,
  ) -> None:
      super().__init__(collect_device, prefix)
      self.valid_symbol = re.compile(valid_symbol)
      if isinstance(mode, str):
          mode = [mode]
      assert mmengine.is_seq_of(mode, str)
      assert set(mode).issubset(
          {"exact", "ignore_case", "ignore_case_symbol"}
      )
      self.mode = set(mode)
  
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 1 to create a new WordMetric object from inherited base classes: BaseMetric with example: obj = WordMetric(mode, valid_symbol, collect_device, prefix)