class_docstr: Point metric for textspotting. Proposed in SPTS.
  
  Args:
      text_score_thrs (dict): Best text score threshold searching
          space. Defaults to dict(start=0.8, stop=1, step=0.01).
      word_spotting (bool): Whether to work in word spotting mode. Defaults
          to False.
      lexicon_path (str, optional): Lexicon path for word spotting, which
          points to a lexicon file or a directory. Defaults to None.
      lexicon_mapping (tuple, optional): The rule to map test image name to
          its corresponding lexicon file. Only effective when lexicon path
          is a directory. Defaults to ('(.*).jpg', r'.txt').
      pair_path (str, optional): Pair path for word spotting, which points
          to a pair file or a directory. Defaults to None.
      pair_mapping (tuple, optional): The rule to map test image name to
          its corresponding pair file. Only effective when pair path is a
          directory. Defaults to ('(.*).jpg', r'.txt').
      match_dist_thr (float, optional): Matching distance threshold for
          word spotting. Defaults to None.
      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: List[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.
      """
      logger: MMLogger = MMLogger.get_current_instance()
  
      best_eval_results = dict(hmean=-1)
  
      num_thres = len(self.text_score_thrs)
      num_preds = np.zeros(
          num_thres, dtype=int
      )  # the number of points actually predicted
      num_tp = np.zeros(
          num_thres, dtype=int
      )  # number of true positives
      num_gts = np.zeros(num_thres, dtype=int)  # number of valid gts
  
      for result in results:
          text_scores = result["text_scores"]
          pred_points = result["pred_points"]
          gt_points = result["gt_points"]
          gt_texts = result["gt_texts"]
          pred_texts = result["pred_texts"]
          gt_ignore_flags = result["gt_ignore_flags"]
          gt_img_name = result["gt_img_name"]
  
          # Correct the words with lexicon
          pred_dist_flags = np.zeros(len(pred_texts), dtype=bool)
          if hasattr(self, "lexicons"):
              for i, pred_text in enumerate(pred_texts):
                  # If it's an image-level lexicon
                  if isinstance(self.lexicons, dict):
                      lexicon_name = self._map_img_name(
                          gt_img_name, self.lexicon_mapping
                      )
                      pair_name = self._map_img_name(
                          gt_img_name, self.pair_mapping
                      )
                      pred_texts[i], match_dist = self._match_word(
                          pred_text,
                          self.lexicons[lexicon_name],
                          self.pairs[pair_name],
                      )
                  else:
                      pred_texts[i], match_dist = self._match_word(
                          pred_text, self.lexicons, self.pairs
                      )
                  if (
                      self.match_dist_thr
                      and match_dist >= self.match_dist_thr
                  ):
                      # won't even count this as a prediction
                      pred_dist_flags[i] = True
  
          # Filter out predictions by IoU threshold
          for i, text_score_thr in enumerate(self.text_score_thrs):
              pred_ignore_flags = pred_dist_flags | (
                  text_scores < text_score_thr
              )
              filtered_pred_texts = self._get_true_elements(
                  pred_texts, ~pred_ignore_flags
              )
              filtered_pred_points = self._get_true_elements(
                  pred_points, ~pred_ignore_flags
              )
              gt_matched = np.zeros(len(gt_texts), dtype=bool)
              num_gt = len(gt_texts) - np.sum(gt_ignore_flags)
              if num_gt == 0:
                  continue
              num_gts[i] += num_gt
  
              for pred_text, pred_point in zip(
                  filtered_pred_texts, filtered_pred_points
              ):
                  dists = [
                      Point(pred_point).distance(Point(gt_point))
                      for gt_point in gt_points
                  ]
                  min_idx = np.argmin(dists)
                  if (
                      gt_texts[min_idx] == "###"
                      or gt_ignore_flags[min_idx]
                  ):
                      continue
                  if not gt_matched[min_idx] and (
                      pred_text.upper() == gt_texts[min_idx].upper()
                  ):
                      gt_matched[min_idx] = True
                      num_tp[i] += 1
                  num_preds[i] += 1
  
      for i, text_score_thr in enumerate(self.text_score_thrs):
          if num_preds[i] == 0 or num_tp[i] == 0:
              recall, precision, hmean = 0, 0, 0
          else:
              recall = num_tp[i] / num_gts[i]
              precision = num_tp[i] / num_preds[i]
              hmean = 2 * recall * precision / (recall + precision)
          eval_results = dict(
              precision=precision, recall=recall, hmean=hmean
          )
          logger.info(
              f"text score threshold: {text_score_thr:.2f}, "
              f'recall: {eval_results["recall"]:.4f}, '
              f'precision: {eval_results["precision"]:.4f}, '
              f'hmean: {eval_results["hmean"]:.4f}\n'
          )
          if eval_results["hmean"] > best_eval_results["hmean"]:
              best_eval_results = eval_results
      return best_eval_results
  
imports: import glob
  import os.path
  import re
  from typing import Dict, List, Optional, Sequence, Tuple
  import numpy
  import torch
  from mmengine.evaluator import BaseMetric
  from mmengine.logging import MMLogger
  from rapidfuzz.distance import Levenshtein
  from shapely.geometry import Point
  from mmocr.registry import METRICS
label_desc: Use image node_id 7 for calling the E2EPointMetric obj's underlying member method code with example usage: obj.compute_metrics(results) and returns: best_eval_results