code: def test_rescale_polygons(self):
      polygons = [
          np.array([0, 0, 1, 0, 1, 1, 0, 1]),
          np.array([1, 1, 2, 1, 2, 2, 1, 2]),
      ]
      scale_factor = (0.5, 0.5)
      self.assertTrue(
          np.allclose(
              rescale_polygons(polygons, scale_factor, mode="div"),
              [
                  np.array([0, 0, 2, 0, 2, 2, 0, 2]),
                  np.array([2, 2, 4, 2, 4, 4, 2, 4]),
              ],
          )
      )
      self.assertTrue(
          np.allclose(
              rescale_polygons(polygons, scale_factor, mode="mul"),
              [
                  np.array([0, 0, 0.5, 0, 0.5, 0.5, 0, 0.5]),
                  np.array([0.5, 0.5, 1, 0.5, 1, 1, 0.5, 1]),
              ],
          )
      )
  
      polygons = np.array(
          [[0, 0, 1, 0, 1, 1, 0, 1], [1, 1, 2, 1, 2, 2, 1, 2]]
      )
      scale_factor = (0.5, 0.5)
      self.assertTrue(
          np.allclose(
              rescale_polygons(polygons, scale_factor, mode="div"),
              np.array(
                  [[0, 0, 2, 0, 2, 2, 0, 2], [2, 2, 4, 2, 4, 4, 2, 4]]
              ),
          )
      )
      self.assertTrue(
          np.allclose(
              rescale_polygons(polygons, scale_factor, mode="mul"),
              np.array(
                  [
                      [0, 0, 0.5, 0, 0.5, 0.5, 0, 0.5],
                      [0.5, 0.5, 1, 0.5, 1, 1, 0.5, 1],
                  ]
              ),
          )
      )
  
      polygons = [torch.Tensor([0, 0, 1, 0, 1, 1, 0, 1])]
      scale_factor = (0.3, 0.4)
      self.assertTrue(
          np.allclose(
              rescale_polygons(polygons, scale_factor, mode="div"),
              [
                  np.array(
                      [0, 0, 1 / 0.3, 0, 1 / 0.3, 1 / 0.4, 0, 1 / 0.4]
                  )
              ],
          )
      )
      self.assertTrue(
          np.allclose(
              rescale_polygons(polygons, scale_factor, mode="mul"),
              [np.array([0, 0, 0.3, 0, 0.3, 0.4, 0, 0.4])],
          )
      )
  
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 3 for calling the TestPolygonUtils obj's underlying member method code with example usage: obj.test_rescale_polygons() without return types