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: Process one batch of data_samples. The processed results should be
  stored in ``self.results``, which will be used to compute the metrics
  when all batches have been processed.
  
  Args:
      data_batch (Sequence[Dict]): A batch of gts.
      data_samples (Sequence[Dict]): A batch of outputs from the model.
docstr_tok: ["Process","one","batch","of","data_samples",".","The","processed","results","should","be","stored","in","``","self.results","``",",","which","will","be","used","to","compute","the","metrics","when","all","batches","have","been","processed",".","Args",":","data_batch","(","Sequence","[","Dict","]",")",":","A","batch","of","gts",".","data_samples","(","Sequence","[","Dict","]",")",":","A","batch","of","outputs","from","the","model","."]
code: def process(
      self, data_batch: Sequence[Dict], data_samples: Sequence[Dict]
  ) -> None:
      """Process one batch of data_samples. The processed results should be
      stored in ``self.results``, which will be used to compute the metrics
      when all batches have been processed.
  
      Args:
          data_batch (Sequence[Dict]): A batch of gts.
          data_samples (Sequence[Dict]): A batch of outputs from the model.
      """
      for data_sample in data_samples:
          match_num = 0
          match_ignore_case_num = 0
          match_ignore_case_symbol_num = 0
          pred_text = data_sample.get("pred_text").get("item")
          gt_text = data_sample.get("gt_text").get("item")
          if (
              "ignore_case" in self.mode
              or "ignore_case_symbol" in self.mode
          ):
              pred_text_lower = pred_text.lower()
              gt_text_lower = gt_text.lower()
          if "ignore_case_symbol" in self.mode:
              gt_text_lower_ignore = self.valid_symbol.sub(
                  "", gt_text_lower
              )
              pred_text_lower_ignore = self.valid_symbol.sub(
                  "", pred_text_lower
              )
              match_ignore_case_symbol_num = (
                  gt_text_lower_ignore == pred_text_lower_ignore
              )
          if "ignore_case" in self.mode:
              match_ignore_case_num = pred_text_lower == gt_text_lower
          if "exact" in self.mode:
              match_num = pred_text == gt_text
          result = dict(
              match_num=match_num,
              match_ignore_case_num=match_ignore_case_num,
              match_ignore_case_symbol_num=match_ignore_case_symbol_num,
          )
          self.results.append(result)
  
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 2 for calling the WordMetric obj's underlying member method code with example usage: obj.process(data_batch, data_samples) without return types