class_docstr: Base postprocessor for text detection models.
  
  Args:
      text_repr_type (str): The boundary encoding type, 'poly' or 'quad'.
          Defaults to 'poly'.
      rescale_fields (list[str], optional): The bbox/polygon field names to
          be rescaled. If None, no rescaling will be performed.
      train_cfg (dict, optional): The parameters to be passed to
          ``self.get_text_instances`` in training. Defaults to None.
      test_cfg (dict, optional): The parameters to be passed to
          ``self.get_text_instances`` in testing. Defaults to None.
class_docstr_tok: ["Base","postprocessor","for","text","detection","models",".","Args",":","text_repr_type","(","str",")",":","The","boundary","encoding","type",",","'poly","'","or","'quad","'",".","Defaults","to","'poly","'",".","rescale_fields","(","list","[","str","]",",","optional",")",":","The","bbox\/polygon","field","names","to","be","rescaled",".","If","None",",","no","rescaling","will","be","performed",".","train_cfg","(","dict",",","optional",")",":","The","parameters","to","be","passed","to","``","self.get_text_instances","``","in","training",".","Defaults","to","None",".","test_cfg","(","dict",",","optional",")",":","The","parameters","to","be","passed","to","``","self.get_text_instances","``","in","testing",".","Defaults","to","None","."]
docstr: Non-maximum suppression for text detection.
  
  Args:
      polygons (list[ndarray]): List of polygons.
      scores (list[float]): List of scores.
      threshold (float): Threshold for NMS.
  
  Returns:
      tuple(keep_polys, keep_scores):
  
      - keep_polys (list[ndarray]): List of preserved polygons after NMS.
      - keep_scores (list[float]): List of preserved scores after NMS.
docstr_tok: ["Non-maximum","suppression","for","text","detection",".","Args",":","polygons","(","list","[","ndarray","]",")",":","List","of","polygons",".","scores","(","list","[","float","]",")",":","List","of","scores",".","threshold","(","float",")",":","Threshold","for","NMS",".","Returns",":","tuple","(","keep_polys",",","keep_scores",")",":","-","keep_polys","(","list","[","ndarray","]",")",":","List","of","preserved","polygons","after","NMS",".","-","keep_scores","(","list","[","float","]",")",":","List","of","preserved","scores","after","NMS","."]
code: def poly_nms(
      self,
      polygons: List[np.ndarray],
      scores: List[float],
      threshold: float,
  ) -> Tuple[List[np.ndarray], List[float]]:
      """Non-maximum suppression for text detection.
  
      Args:
          polygons (list[ndarray]): List of polygons.
          scores (list[float]): List of scores.
          threshold (float): Threshold for NMS.
  
      Returns:
          tuple(keep_polys, keep_scores):
  
          - keep_polys (list[ndarray]): List of preserved polygons after NMS.
          - keep_scores (list[float]): List of preserved scores after NMS.
      """
      assert isinstance(polygons, list)
      assert isinstance(scores, list)
      assert len(polygons) == len(scores)
  
      polygons = [
          np.hstack((polygon, score))
          for polygon, score in zip(polygons, scores)
      ]
      polygons = np.array(sorted(polygons, key=lambda x: x[-1]))
      keep_polys = []
      keep_scores = []
      index = [i for i in range(len(polygons))]
  
      while len(index) > 0:
          keep_polys.append(polygons[index[-1]][:-1].tolist())
          keep_scores.append(polygons[index[-1]][-1])
          A = polygons[index[-1]][:-1]
          index = np.delete(index, -1)
  
          iou_list = np.zeros((len(index),))
          for i in range(len(index)):
              B = polygons[index[i]][:-1]
  
              iou_list[i] = boundary_iou(A, B, 1)
          remove_index = np.where(iou_list > threshold)
          index = np.delete(index, remove_index)
  
      return keep_polys, keep_scores
  
file_path: mmocr/mmocr/models/textdet/postprocessors/base.py
imports: from functools import partial
  from typing import Dict, List, Optional, Sequence, Tuple, Union
  import mmengine
  import numpy
  from torch import Tensor
  from mmocr.structures import TextDetDataSample
  from mmocr.utils import boundary_iou, rescale_polygons
label_desc: Use image node_id 7 for calling the BaseTextDetPostProcessor obj's underlying member method code with example usage: obj.poly_nms(polygons, scores, threshold) and returns: keep_polys,  keep_scores