code: def intersection(g, p):
      """
      Intersection.
      """
  
      g = g[:8].reshape((4, 2))
      p = p[:8].reshape((4, 2))
  
      a = g
      b = p
  
      use_filter = True
      if use_filter:
          # step1:
          inter_x1 = np.maximum(np.min(a[:, 0]), np.min(b[:, 0]))
          inter_x2 = np.minimum(np.max(a[:, 0]), np.max(b[:, 0]))
          inter_y1 = np.maximum(np.min(a[:, 1]), np.min(b[:, 1]))
          inter_y2 = np.minimum(np.max(a[:, 1]), np.max(b[:, 1]))
          if inter_x1 >= inter_x2 or inter_y1 >= inter_y2:
              return 0.0
          x1 = np.minimum(np.min(a[:, 0]), np.min(b[:, 0]))
          x2 = np.maximum(np.max(a[:, 0]), np.max(b[:, 0]))
          y1 = np.minimum(np.min(a[:, 1]), np.min(b[:, 1]))
          y2 = np.maximum(np.max(a[:, 1]), np.max(b[:, 1]))
          if x1 >= x2 or y1 >= y2 or (x2 - x1) < 2 or (y2 - y1) < 2:
              return 0.0
  
      g = Polygon(g)
      p = Polygon(p)
      if not g.is_valid or not p.is_valid:
          return 0
  
      inter = Polygon(g).intersection(Polygon(p)).area
      union = g.area + p.area - inter
      if union == 0:
          return 0
      else:
          return inter / union
  
file_path: PaddleDetection/ppdet/ext_op/unittest/test_matched_rbox_iou.py
imports: import numpy
  import sys
  import time
  from shapely.geometry import Polygon
  import paddle
  import unittest
  from ext_op import matched_rbox_iou
label_desc: Use image node_id 2 for calling a global function with example usage: intersection(g, p) and returns: int, int, unknown, int, int