def compute_segment_ious(preds, gts, sparse=False):
    """Computes the pairwise IoUs between the predicted and ground truth
    temporal detections.

    Args:
        preds: a list of predicted
            :class:`fiftyone.core.labels.TemporalDetection` instances
        gts: a list of ground truth
            :class:`fiftyone.core.labels.TemporalDetection` instances
        sparse (False): whether to return a sparse dict of non-zero IoUs rather
            than a full matrix

    Returns:
        a ``num_preds x num_gts`` array of segment IoUs when ``sparse=False``,
        or a dict of the form ``d[pred.id] = [(gt.id, iou), ...]`` when
        ``sparse=True``
    """
    if not preds or not gts:
        if sparse:
            return {p.id: [] for p in preds}
        else:
            return np.zeros((len(preds or []), len(gts or [])))

    return _compute_segment_ious(preds, gts, sparse=sparse)
Computes the pairwise IoUs between the predicted and ground truth
    temporal detections.

    Args:
        preds: a list of predicted
            :class:`fiftyone.core.labels.TemporalDetection` instances
        gts: a list of ground truth
            :class:`fiftyone.core.labels.TemporalDetection` instances
        sparse (False): whether to return a sparse dict of non-zero IoUs rather
            than a full matrix

    Returns:
        a ``num_preds x num_gts`` array of segment IoUs when ``sparse=False``,
        or a dict of the form ``d[pred.id] = [(gt.id, iou), ...]`` when
        ``sparse=True``
    
fiftyone/utils/iou.py