code: def box_iou(
      boxes1: tf.Tensor, boxes2: tf.Tensor, eps=1e-6
  ) -> Tuple[tf.Tensor, tf.Tensor]:
      """Computes IoU (Intesection over Union) between two sets of boxes.
  
      See https://en.wikipedia.org/wiki/Jaccard_index for definition and visual
      example of IoU for bounding boxes.
  
      Boxes are in [xmin, ymin, xmax, ymax] format.
  
      Args:
        boxes1: Bounding-boxes in shape [bs, n, 4].
        boxes2: Bounding-boxes in shape [bs, m, 4].
        eps: Small floating point number used to avoid division by zero.
  
      Returns:
        Pairwise IoU and union matrices of shape [bs, n, m].
      """
  
      # First, compute box areas. These will be used later for computing the
      # union.
      width_height1 = boxes1[..., 2:] - boxes1[..., :2]
      area1 = width_height1[..., 0] * width_height1[..., 1]  # [bs, n]
  
      width_height2 = boxes2[..., 2:] - boxes2[..., :2]
      area2 = width_height2[..., 0] * width_height2[..., 1]  # [bs, m]
  
      # Compute pairwise top-left and bottom-right corners of the intersection
      # of the boxes.
      left_top = tf.maximum(
          boxes1[..., :, None, :2], boxes2[..., None, :, :2]
      )  # [bs, n, m, 2].
      right_bottom = tf.minimum(
          boxes1[..., :, None, 2:], boxes2[..., None, :, 2:]
      )  # [bs, n, m, 2].
  
      # Intersection = area of the box defined by [left_top, right_bottom].
      width_height = tf.maximum(
          right_bottom - left_top, 0.0
      )  # [bs, n, m, 2].
      intersection = (
          width_height[..., 0] * width_height[..., 1]
      )  # [bs, n, m].
  
      # Union = sum of areas - intersection.
      union = area1[..., :, None] + area2[..., None, :] - intersection
  
      iou = intersection / (union + eps)
  
      return iou, union
  
file_path: scenic/scenic/projects/owl_vit/preprocessing/transforms.py
imports: from typing import Any, Optional, Sequence, Tuple, Union
  import tensorflow
label_desc: Use image node_id 3 for calling a global function with example usage: box_iou(boxes1, boxes2, eps) and returns: iou,  union