import torch


def _reduce_camera_iou_overlap(ious: torch.Tensor, topk: int = 2) -> torch.Tensor:
    """
    Calculate the final camera difficulty by computing the average of the
    ious of the two most similar cameras.

    Returns:
        single-element Tensor
    """
    # pyre-ignore[16]  topk not recognized
    return ious.topk(k=min(topk, len(ious) - 1)).values.mean()