code: def test_crop_polygon(self):
      # polygon cross box
      polygon = np.array(
          [20.0, -10.0, 40.0, 10.0, 10.0, 40.0, -10.0, 20.0]
      )
      crop_box = np.array([0.0, 0.0, 60.0, 60.0])
      target_poly_cropped = np.array(
          [10, 40, 0, 30, 0, 10, 10, 0, 30, 0, 40, 10]
      )
      poly_cropped = crop_polygon(polygon, crop_box)
      self.assertTrue(
          poly2shapely(poly_cropped).equals(
              poly2shapely(target_poly_cropped)
          )
      )
  
      # polygon inside box
      polygon = np.array([0.0, 0.0, 30.0, 0.0, 30.0, 30.0, 0.0, 30.0])
      crop_box = np.array([0.0, 0.0, 60.0, 60.0])
      target_poly_cropped = polygon
      poly_cropped = crop_polygon(polygon, crop_box)
      self.assertTrue(
          poly2shapely(poly_cropped).equals(
              poly2shapely(target_poly_cropped)
          )
      )
  
      # polygon outside box
      polygon = np.array([0.0, 0.0, 30.0, 0.0, 30.0, 30.0, 0.0, 30.0])
      crop_box = np.array([80.0, 80.0, 90.0, 90.0])
      poly_cropped = crop_polygon(polygon, crop_box)
      self.assertEqual(poly_cropped, None)
  
      # polygon and box are overlapped at a point
      polygon = np.array([0.0, 0.0, 10.0, 0.0, 10.0, 10.0, 0.0, 10.0])
      crop_box = np.array([10.0, 10.0, 20.0, 20.0])
      poly_cropped = crop_polygon(polygon, crop_box)
      self.assertEqual(poly_cropped, None)
  
imports: import unittest
  from itertools import chain, permutations
  import numpy
  import torch
  from shapely.geometry import MultiPolygon, Polygon
  from mmocr.utils import boundary_iou, crop_polygon, offset_polygon, poly2bbox, poly2shapely, poly_intersection, poly_iou, poly_make_valid, poly_union, polys2shapely, rescale_polygon, rescale_polygons, shapely2poly, sort_points, sort_vertex, sort_vertex8
label_desc: Use image node_id 1 for calling the TestPolygonUtils obj's underlying member method code with example usage: obj.test_crop_polygon() without return types