class_docstr: Fix invalid polygons in the dataset.
  
  Required Keys:
  
  - gt_polygons
  - gt_ignored (optional)
  - gt_bboxes (optional)
  - gt_bboxes_labels (optional)
  - gt_texts (optional)
  
  Modified Keys:
  
  - gt_polygons
  - gt_ignored (optional)
  - gt_bboxes (optional)
  - gt_bboxes_labels (optional)
  - gt_texts (optional)
  
  Args:
      mode (str): The mode of fixing invalid polygons. Options are 'fix' and
          'ignore'.
          For the 'fix' mode, the transform will try to fix
          the invalid polygons to a valid one by eliminating the
          self-intersection or converting the bboxes to polygons. If
          it can't be fixed by any means (e.g. the polygon contains less
          than 3 points or it's actually a line/point), the annotation will
          be removed.
          For the 'ignore' mode, the invalid polygons
          will be set to "ignored" during training.
          Defaults to 'fix'.
      min_poly_points (int): Minimum number of the coordinate points in a
          polygon. Defaults to 4.
      fix_from_bbox (bool): Whether to convert the bboxes to polygons when
          the polygon is invalid and not directly fixable. Defaults to True.
class_docstr_tok: ["Fix","invalid","polygons","in","the","dataset",".","Required","Keys",":","-","gt_polygons","-","gt_ignored","(","optional",")","-","gt_bboxes","(","optional",")","-","gt_bboxes_labels","(","optional",")","-","gt_texts","(","optional",")","Modified","Keys",":","-","gt_polygons","-","gt_ignored","(","optional",")","-","gt_bboxes","(","optional",")","-","gt_bboxes_labels","(","optional",")","-","gt_texts","(","optional",")","Args",":","mode","(","str",")",":","The","mode","of","fixing","invalid","polygons",".","Options","are","'fix","'","and","'ignore","'",".","For","the","'fix","'","mode",",","the","transform","will","try","to","fix","the","invalid","polygons","to","a","valid","one","by","eliminating","the","self-intersection","or","converting","the","bboxes","to","polygons",".","If","it","ca","n't","be","fixed","by","any","means","(","e.g",".","the","polygon","contains","less","than","3","points","or","it","'s","actually","a","line\/point",")",",","the","annotation","will","be","removed",".","For","the","'ignore","'","mode",",","the","invalid","polygons","will","be","set","to","``","ignored","''","during","training",".","Defaults","to","'fix","'",".","min_poly_points","(","int",")",":","Minimum","number","of","the","coordinate","points","in","a","polygon",".","Defaults","to","4.","fix_from_bbox","(","bool",")",":","Whether","to","convert","the","bboxes","to","polygons","when","the","polygon","is","invalid","and","not","directly","fixable",".","Defaults","to","True","."]
code: def __init__(
      self,
      mode: str = "fix",
      min_poly_points: int = 4,
      fix_from_bbox: bool = True,
  ) -> None:
      super().__init__()
      self.mode = mode
      assert (
          min_poly_points >= 3
      ), "min_poly_points must be greater than 3."
      self.min_poly_points = min_poly_points
      self.fix_from_bbox = fix_from_bbox
      assert self.mode in [
          "fix",
          "ignore",
      ], f"Supported modes are 'fix' and 'ignore', but got {self.mode}"
  
imports: import math
  from typing import Dict, Tuple
  import cv2
  import mmcv
  import numpy
  from mmcv.transforms import Resize
  from mmcv.transforms.base import BaseTransform
  from mmcv.transforms.utils import avoid_cache_randomness, cache_randomness
  from mmocr.registry import TRANSFORMS
  from mmocr.utils import bbox2poly, crop_polygon, is_poly_inside_rect, poly2bbox, poly2shapely, poly_make_valid, remove_pipeline_elements, rescale_polygon, shapely2poly
  from .wrappers import ImgAugWrapper
label_desc: Use image node_id 1 to create a new FixInvalidPolygon object from inherited base classes: BaseTransform with example: obj = FixInvalidPolygon(mode, min_poly_points, fix_from_bbox)