class_docstr: Merge text components and construct boundaries of text instances.
  
  Args:
      link_thr (float): The edge score threshold. Defaults to 0.8.
      edge_len_thr (int or float): The edge length threshold. Defaults to 50.
      rescale_fields (list[str]): The bbox/polygon field names to
          be rescaled. If None, no rescaling will be performed. Defaults to
          [polygons'].
docstr: Construct text instance boundaries from clustered text components.
  This code was partially adapted from https://github.com/GXYM/DRRG
  licensed under the MIT license.
  
  Args:
      text_comps (ndarray): The text components.
      comp_pred_labels (ndarray): The clustering labels of text
          components.
  
  Returns:
      tuple(boundaries, scores):
  
      - boundaries (list[ndarray]): The predicted boundaries of text
        instances.
      - scores (list[float]): The boundary scores.
docstr_tok: ["Construct","text","instance","boundaries","from","clustered","text","components",".","This","code","was","partially","adapted","from","https",":","\/\/github.com\/GXYM\/DRRG","licensed","under","the","MIT","license",".","Args",":","text_comps","(","ndarray",")",":","The","text","components",".","comp_pred_labels","(","ndarray",")",":","The","clustering","labels","of","text","components",".","Returns",":","tuple","(","boundaries",",","scores",")",":","-","boundaries","(","list","[","ndarray","]",")",":","The","predicted","boundaries","of","text","instances",".","-","scores","(","list","[","float","]",")",":","The","boundary","scores","."]
code: def _comps2polys(
      self, text_comps: ndarray, comp_pred_labels: ndarray
  ) -> Tuple[List[ndarray], List[float]]:
      """Construct text instance boundaries from clustered text components.
      This code was partially adapted from https://github.com/GXYM/DRRG
      licensed under the MIT license.
  
      Args:
          text_comps (ndarray): The text components.
          comp_pred_labels (ndarray): The clustering labels of text
              components.
  
      Returns:
          tuple(boundaries, scores):
  
          - boundaries (list[ndarray]): The predicted boundaries of text
            instances.
          - scores (list[float]): The boundary scores.
      """
      assert text_comps.ndim == 2
      assert len(text_comps) == len(comp_pred_labels)
      boundaries = []
      scores = []
      if len(text_comps) < 1:
          return boundaries, scores
      for cluster_ind in range(0, int(np.max(comp_pred_labels)) + 1):
          cluster_comp_inds = np.where(comp_pred_labels == cluster_ind)
          text_comp_boxes = (
              text_comps[cluster_comp_inds, :8]
              .reshape((-1, 4, 2))
              .astype(np.int32)
          )
          score = np.mean(text_comps[cluster_comp_inds, -1])
  
          if text_comp_boxes.shape[0] < 1:
              continue
  
          elif text_comp_boxes.shape[0] > 1:
              centers = (
                  np.mean(text_comp_boxes, axis=1)
                  .astype(np.int32)
                  .tolist()
              )
              shortest_path = self._min_connect_path(centers)
              text_comp_boxes = text_comp_boxes[shortest_path]
              top_line = (
                  np.mean(text_comp_boxes[:, 0:2, :], axis=1)
                  .astype(np.int32)
                  .tolist()
              )
              bot_line = (
                  np.mean(text_comp_boxes[:, 2:4, :], axis=1)
                  .astype(np.int32)
                  .tolist()
              )
              top_line, bot_line = self._fix_corner(
                  top_line,
                  bot_line,
                  text_comp_boxes[0],
                  text_comp_boxes[-1],
              )
              boundary_points = top_line + bot_line[::-1]
  
          else:
              top_line = (
                  text_comp_boxes[0, 0:2, :].astype(np.int32).tolist()
              )
              bot_line = (
                  text_comp_boxes[0, 2:4:-1, :]
                  .astype(np.int32)
                  .tolist()
              )
              boundary_points = top_line + bot_line
  
          boundary = [p for coord in boundary_points for p in coord]
          boundaries.append(np.array(boundary, dtype=np.float32))
          scores.append(score)
  
      return boundaries, scores
  
imports: import functools
  import operator
  from typing import Dict, List, Tuple, Union
  import cv2
  import numpy
  import torch
  from mmengine.structures import InstanceData
  from numpy import ndarray
  from mmocr.registry import MODELS
  from mmocr.structures import TextDetDataSample
  from .base import BaseTextDetPostProcessor
label_desc: Use image node_id 8 for calling the DRRGPostprocessor obj's underlying member method code with example usage: obj._comps2polys(text_comps, comp_pred_labels) and returns: boundaries,  scores, boundaries,  scores