def METHOD_NAME(self, boxes1, boxes2):
    boxes1_rank = len(boxes1.shape)
    boxes2_rank = len(boxes2.shape)
    if boxes1_rank not in [2, 3]:
        raise ValueError(
            "compute_iou() expects boxes1 to be batched, or to be "
            f"unbatched. Received len(boxes1.shape)={boxes1_rank}, "
            f"len(boxes2.shape)={boxes2_rank}. Expected either "
            "len(boxes1.shape)=2 AND or len(boxes1.shape)=3."
        )
    if boxes2_rank not in [2, 3]:
        raise ValueError(
            "compute_iou() expects boxes2 to be batched, or to be "
            f"unbatched. Received len(boxes1.shape)={boxes1_rank}, "
            f"len(boxes2.shape)={boxes2_rank}. Expected either "
            "len(boxes2.shape)=2 AND or len(boxes2.shape)=3."
        )
    target_format = "yxyx"
    if bounding_box.is_relative(self.bounding_box_format):
        target_format = bounding_box.as_relative(target_format)
    boxes1 = bounding_box.convert_format(
        boxes1, source=self.bounding_box_format, target=target_format
    )
    boxes2 = bounding_box.convert_format(
        boxes2, source=self.bounding_box_format, target=target_format
    )
    intersect_area = bounding_box.iou._compute_intersection(boxes1, boxes2)
    boxes1_area = bounding_box.iou._compute_area(boxes1)
    boxes2_area = bounding_box.iou._compute_area(boxes2)
    boxes2_area_rank = len(boxes2_area.shape)
    boxes2_axis = 1 if (boxes2_area_rank == 2) else 0
    boxes1_area = ops.expand_dims(boxes1_area, axis=-1)
    boxes2_area = ops.expand_dims(boxes2_area, axis=boxes2_axis)
    union_area = boxes1_area + boxes2_area - intersect_area
    iou = ops.divide(intersect_area, union_area + keras.backend.epsilon())
    # giou calculation
    enclose_area = self._compute_enclosure(boxes1, boxes2)
    return iou - ops.divide(
        (enclose_area - union_area), enclose_area + keras.backend.epsilon()
    )