def bbox_overlaps(boxes1, boxes2):
    """
    Parameters
    ----------
    boxes1: (N, 4) ndarray of float
    boxes2: (K, 4) ndarray of float
    Returns
    -------
    overlaps: (N, K) ndarray of overlap between boxes1 and boxes2
    """
    # Calculate the area of each box
    box_areas1 = (boxes1[:, 2] - boxes1[:, 0] + 1) * (
        boxes1[:, 3] - boxes1[:, 1] + 1)
    box_areas2 = (boxes2[:, 2] - boxes2[:, 0] + 1) * (
        boxes2[:, 3] - boxes2[:, 1] + 1)
    # Calculate the intersection areas
    iw = np.minimum(boxes1[:, None, 2], boxes2[None, :, 2]) - np.maximum(
        boxes1[:, None, 0], boxes2[None, :, 0]) + 1
    ih = np.minimum(boxes1[:, None, 3], boxes2[None, :, 3]) - np.maximum(
        boxes1[:, None, 1], boxes2[None, :, 1]) + 1
    # Ensure that the intersection width and height are non-negative
    iw = np.maximum(iw, 0)
    ih = np.maximum(ih, 0)
    # Calculate the intersection area
    intersection = iw * ih
    # Calculate the union area
    union = box_areas1[:, None] + box_areas2[None, :] - intersection
    union = box_areas1[:, None] + box_areas2[None, :] - intersection
    union = np.maximum(union, 1e-8)
    # Calculate the overlaps (intersection over union)
    overlaps = intersection / union
    return overlaps

    Parameters
    ----------
    boxes1: (N, 4) ndarray of float
    boxes2: (K, 4) ndarray of float
    Returns
    -------
    overlaps: (N, K) ndarray of overlap between boxes1 and boxes2
    
ppdet/metrics/widerface_utils.py