code: def poly_intersection(
      poly_a: Polygon,
      poly_b: Polygon,
      invalid_ret: Optional[Union[float, int]] = None,
      return_poly: bool = False,
  ) -> Tuple[float, Optional[Polygon]]:
      """Calculate the intersection area between two polygons.
  
      Args:
          poly_a (Polygon): Polygon a.
          poly_b (Polygon): Polygon b.
          invalid_ret (float or int, optional): The return value when the
              invalid polygon exists. If it is not specified, the function
              allows the computation to proceed with invalid polygons by
              cleaning the their self-touching or self-crossing parts.
              Defaults to None.
          return_poly (bool): Whether to return the polygon of the intersection
              Defaults to False.
  
      Returns:
          float or tuple(float, Polygon): Returns the intersection area or
          a tuple ``(area, Optional[poly_obj])``, where the `area` is the
          intersection area between two polygons and `poly_obj` is The Polygon
          object of the intersection area, which will be `None` if the input is
          invalid. `poly_obj` will be returned only if `return_poly` is `True`.
      """
      assert isinstance(poly_a, Polygon)
      assert isinstance(poly_b, Polygon)
      assert invalid_ret is None or isinstance(
          invalid_ret, (float, int)
      )
  
      if invalid_ret is None:
          poly_a = poly_make_valid(poly_a)
          poly_b = poly_make_valid(poly_b)
  
      poly_obj = None
      area = invalid_ret
      if poly_a.is_valid and poly_b.is_valid:
          if poly_a.intersects(poly_b):
              poly_obj = poly_a.intersection(poly_b)
              area = poly_obj.area
          else:
              poly_obj = Polygon()
              area = 0.0
      return (area, poly_obj) if return_poly else area
  
imports: import math
  import operator
  from functools import reduce
  from typing import List, Optional, Sequence, Tuple, Union
  import numpy
  import pyclipper
  import shapely
  from mmengine.utils import is_list_of
  from shapely.geometry import MultiPolygon, Polygon
  from mmocr.utils import bbox2poly, valid_boundary
  from mmocr.utils.check_argument import is_2dlist
  from mmocr.utils.typing_utils import ArrayLike
label_desc: Use image node_id 9 for calling a global function with example usage: poly_intersection(poly_a, poly_b, invalid_ret, return_poly) and returns: unknown