code: def IOU(ann, centroids):
      w, h = ann
      similarities = []
  
      for centroid in centroids:
          c_w, c_h = centroid
  
          if c_w >= w and c_h >= h:
              similarity = w * h / (c_w * c_h)
          elif c_w >= w and c_h <= h:
              similarity = w * c_h / (w * h + (c_w - w) * c_h)
          elif c_w <= w and c_h >= h:
              similarity = c_w * h / (w * h + c_w * (c_h - h))
          else:  # means both w,h are bigger than c_w and c_h respectively
              similarity = (c_w * c_h) / (w * h)
          similarities.append(similarity)  # will become (k,) shape
  
      return np.array(similarities)
  
imports: import random
  import numpy
  from imageai.Detection.Custom.voc import parse_voc_annotation
label_desc: Use image node_id 1 for calling a global function with example usage: IOU(ann, centroids) and returns: np