class_docstr: Randomly select a region and crop images to a target size and make sure
  to contain text region. This transform may break up text instances, and for
  broken text instances, we will crop it's bbox and polygon coordinates. This
  transform is recommend to be used in segmentation-based network.
  
  Required Keys:
  
  - img
  - gt_polygons
  - gt_bboxes
  - gt_bboxes_labels
  - gt_ignored
  
  Modified Keys:
  
  - img
  - img_shape
  - gt_polygons
  - gt_bboxes
  - gt_bboxes_labels
  - gt_ignored
  
  Args:
      target_size (tuple(int, int) or int): Target size for the cropped
          image. If it's a tuple, then target width and target height will be
          ``target_size[0]`` and ``target_size[1]``, respectively. If it's an
          integer, them both target width and target height will be
          ``target_size``.
      positive_sample_ratio (float): The probability of sampling regions
          that go through text regions. Defaults to 5. / 8.
docstr: Crop polygons to be within a crop region. If polygon crosses the
  crop_bbox, we will keep the part left in crop_bbox by cropping its
  boardline.
  
  Args:
      polygons (list(ndarray)): List of polygons [(N1, ), (N2, ), ...].
      crop_bbox (ndarray): Cropping region. [x1, y1, x2, y1].
  
  Returns
      tuple(List(ArrayLike), list[int]):
          - (List(ArrayLike)): The rest of the polygons located in the
              crop region.
          - (list[int]): Index list of the reserved polygons.
docstr_tok: ["Crop","polygons","to","be","within","a","crop","region",".","If","polygon","crosses","the","crop_bbox",",","we","will","keep","the","part","left","in","crop_bbox","by","cropping","its","boardline",".","Args",":","polygons","(","list","(","ndarray",")",")",":","List","of","polygons","[","(","N1",",",")",",","(","N2",",",")",",","...","]",".","crop_bbox","(","ndarray",")",":","Cropping","region",".","[","x1",",","y1",",","x2",",","y1","]",".","Returns","tuple","(","List","(","ArrayLike",")",",","list","[","int","]",")",":","-","(","List","(","ArrayLike",")",")",":","The","rest","of","the","polygons","located","in","the","crop","region",".","-","(","list","[","int","]",")",":","Index","list","of","the","reserved","polygons","."]
code: def _crop_polygons(
      self, polygons: Sequence[np.ndarray], crop_bbox: np.ndarray
  ) -> Sequence[np.ndarray]:
      """Crop polygons to be within a crop region. If polygon crosses the
      crop_bbox, we will keep the part left in crop_bbox by cropping its
      boardline.
  
      Args:
          polygons (list(ndarray)): List of polygons [(N1, ), (N2, ), ...].
          crop_bbox (ndarray): Cropping region. [x1, y1, x2, y1].
  
      Returns
          tuple(List(ArrayLike), list[int]):
              - (List(ArrayLike)): The rest of the polygons located in the
                  crop region.
              - (list[int]): Index list of the reserved polygons.
      """
      polygons_cropped = []
      kept_idx = []
      for idx, polygon in enumerate(polygons):
          if polygon.size < 6:
              continue
          poly = crop_polygon(polygon, crop_bbox)
          if poly is not None:
              poly = poly.reshape(-1, 2) - (crop_bbox[0], crop_bbox[1])
              polygons_cropped.append(poly.reshape(-1))
              kept_idx.append(idx)
      return (polygons_cropped, kept_idx)
  
imports: import math
  import random
  from typing import Dict, List, Sequence, Tuple, Union
  import cv2
  import mmcv
  import numpy
  from mmcv.transforms import RandomFlip
  from mmcv.transforms.base import BaseTransform
  from mmcv.transforms.utils import avoid_cache_randomness, cache_randomness
  from shapely.geometry import Polygon
  from mmocr.registry import TRANSFORMS
  from mmocr.utils import crop_polygon, poly2bbox, poly_intersection
label_desc: Use image node_id 6 for calling the TextDetRandomCrop obj's underlying member method code with example usage: obj._crop_polygons(polygons, crop_bbox) and returns: polygons_cropped,  kept_idx