code: def iou_rule_match(
      end2end_xyxy_bboxes,
      end2end_xyxy_indexes,
      structure_master_xyxy_bboxes,
  ):
      """
      Use iou to find matching list.
      choose max iou value bbox as match pair.
      :param end2end_xyxy_bboxes:
      :param end2end_xyxy_indexes: original end2end indexes.
      :param structure_master_xyxy_bboxes:
      :return: match pairs list, e.g. [[0,1], [1,2], ...]
      """
      match_pair_list = []
      for end2end_xyxy_index, end2end_xyxy in zip(
          end2end_xyxy_indexes, end2end_xyxy_bboxes
      ):
          max_iou = 0
          max_match = [None, None]
          for j, master_xyxy in enumerate(structure_master_xyxy_bboxes):
              end2end_4xy = convert_coord(end2end_xyxy)
              master_4xy = convert_coord(master_xyxy)
              iou = cal_iou(end2end_4xy, master_4xy)
              if iou > max_iou:
                  max_match[0], max_match[1] = end2end_xyxy_index, j
                  max_iou = iou
  
          if max_match[0] is None:
              # no match
              continue
          match_pair_list.append(max_match)
      return match_pair_list
  
imports: import os
  import re
  import cv2
  import glob
  import copy
  import math
  import pickle
  import numpy
  from shapely.geometry import Polygon, MultiPoint
label_desc: Use image node_id 16 for calling a global function with example usage: iou_rule_match(end2end_xyxy_bboxes, end2end_xyxy_indexes, structure_master_xyxy_bboxes) and returns: match_pair_list