import tensorflow as tf


    Returns:
      a tensor with shape [N, M] representing pairwise iou scores.
    """
    intersections = pairwise_intersection(boxlist1, boxlist2)
    areas1 = area(boxlist1)
    areas2 = area(boxlist2)
    unions = (
        tf.expand_dims(areas1, 1) + tf.expand_dims(areas2, 0) - intersections)
    return tf.where(
        tf.equal(intersections, 0.0),
        tf.zeros_like(intersections), tf.truediv(intersections, unions))



@under_name_scope()
def pairwise_iou_batch(proposal_boxes, gt_boxes, orig_gt_counts, batch_size):
    """Computes pairwise intersection-over-union between box collections.
    Args:
      proposal_boxes: K x 5  (batch_index, x1, y1, x2, y2)
      gt_boxes: BS x MaxNumGTs x 4
      orig_gt_counts: BS
