code: def test_poly_union(self):
      # test unsupported type
      with self.assertRaises(AssertionError):
          poly_union(0, 1)
  
      # test non-overlapping polygons
  
      points = [0, 0, 0, 1, 1, 1, 1, 0]
      points1 = [2, 2, 2, 3, 3, 3, 3, 2]
      points2 = [0, 0, 0, 0, 0, 0, 0, 0]  # Invalid polygon
      points3 = [0, 0, 0, 1, 1, 0, 1, 1]  # Self-intersected polygon
      points4 = [0.5, 0.5, 1, 0, 1, 1, 0.5, 0.5]
      poly = poly2shapely(points)
      poly1 = poly2shapely(points1)
      poly2 = poly2shapely(points2)
      poly3 = poly2shapely(points3)
      poly4 = poly2shapely(points4)
  
      assert poly_union(poly, poly1) == 2
  
      # test overlapping polygons
      assert poly_union(poly, poly) == 1
  
      # test invalid polygons
      self.assertEqual(poly_union(poly2, poly2), 0)
      self.assertEqual(poly_union(poly3, poly3, invalid_ret=1), 1)
  
      # The return value depends on the implementation of the package
      self.assertEqual(poly_union(poly3, poly3, invalid_ret=None), 0.25)
      self.assertEqual(poly_union(poly2, poly3), 0.25)
      self.assertEqual(poly_union(poly3, poly4), 0.5)
  
      # test poly return
      _, poly = poly_union(poly, poly1, return_poly=True)
      self.assertTrue(isinstance(poly, MultiPolygon))
      _, poly = poly_union(poly3, poly3, return_poly=True)
      self.assertTrue(isinstance(poly, Polygon))
      _, poly = poly_union(
          poly2, poly3, invalid_ret=0, return_poly=True
      )
      self.assertTrue(poly is 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 10 for calling the TestPolygonUtils obj's underlying member method code with example usage: obj.test_poly_union() without return types