class_docstr: Character metrics for text recognition task.
  
  Args:
      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:
          pred_text = data_sample.get("pred_text").get("item")
          gt_text = data_sample.get("gt_text").get("item")
          gt_text_lower = gt_text.lower()
          pred_text_lower = pred_text.lower()
          gt_text_lower_ignore = self.valid_symbol.sub(
              "", gt_text_lower
          )
          pred_text_lower_ignore = self.valid_symbol.sub(
              "", pred_text_lower
          )
          # number to calculate char level recall & precision
          result = dict(
              gt_char_num=len(gt_text_lower_ignore),
              pred_char_num=len(pred_text_lower_ignore),
              true_positive_char_num=self._cal_true_positive_char(
                  pred_text_lower_ignore, gt_text_lower_ignore
              ),
          )
          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 CharMetric obj's underlying member method code with example usage: obj.process(data_batch, data_samples) without return types