code: def polygon_iou(poly1, poly2):
      """
      Intersection over union between two shapely polygons.
      """
      if not poly1.intersects(
          poly2
      ):  # this test is fast and can accelerate calculation
          iou = 0
      else:
          try:
              inter_area = poly1.intersection(poly2).area
              union_area = poly1.area + poly2.area - inter_area
              iou = float(inter_area) / union_area
          except shapely.geos.TopologicalError:
              # except Exception as e:
              #     print(e)
              print(
                  "shapely.geos.TopologicalError occurred, iou set to 0"
              )
              iou = 0
      return iou
  
file_path: PaddleOCR/ppstructure/kie/tools/eval_with_label_end2end.py
imports: import os
  import re
  import sys
  import shapely
  from shapely.geometry import Polygon
  import numpy
  from collections import defaultdict
  import operator
  from rapidfuzz.distance import Levenshtein
  import argparse
  import json
  import copy
label_desc: Use image node_id 3 for calling a global function with example usage: polygon_iou(poly1, poly2) and returns: iou