code: def test_transform_fix(self):
      transform = FixInvalidPolygon(mode="fix", min_poly_points=4)
      results = transform(copy.deepcopy(self.data_info))
      # The third one is removed because it doesn't have enough points
      # The fourth one is removed because it is a line
      assert (
          len(results["gt_polygons"])
          == len(self.data_info["gt_polygons"]) - 2
      )
      for poly in results["gt_polygons"]:
          self.assertTrue(poly2shapely(poly).is_valid)
      results = transform(copy.deepcopy(self.data_info2))
      # The fourth one is removed because it is a line, and its bbox is also
      # invalid
      assert (
          len(results["gt_polygons"])
          == len(self.data_info["gt_polygons"]) - 1
      )
      for poly in results["gt_polygons"]:
          self.assertTrue(len(poly) >= 8 and len(poly) % 2 == 0)
      # test not fixing the invalid polygons from bboxes
      transform_wo_bbox = FixInvalidPolygon(
          mode="fix", min_poly_points=4, fix_from_bbox=False
      )
      results = transform_wo_bbox(copy.deepcopy(self.data_info2))
      # The fourth one is removed because it is a line, and its bbox is also
      # invalid
      assert (
          len(results["gt_polygons"])
          == len(self.data_info["gt_polygons"]) - 2
      )
      for poly in results["gt_polygons"]:
          self.assertTrue(len(poly) >= 8 and len(poly) % 2 == 0)
      # Fixing all invalid polygons would result in an empty result dict,
      # and therefore the transform would return None
      results = transform(copy.deepcopy(self.data_info3))
      self.assertIsNone(results)
      # If no gt_polygon inside
      results = transform(copy.deepcopy(self.data_info5))
      for k, v in results.items():
          self.assertTrue(np.array_equal(v, self.data_info5[k]))
  
imports: import copy
  import unittest
  import unittest.mock
  import numpy
  from mmocr.datasets.transforms import FixInvalidPolygon, RandomCrop, RandomRotate, RemoveIgnored, Resize
  from mmocr.utils import poly2shapely
label_desc: Use image node_id 2 for calling the TestFixInvalidPolygon obj's underlying member method code with example usage: obj.test_transform_fix() without return types