def test_aupro(labels: torch.Tensor, preds: torch.Tensor, fpr_limit: float, expected_aupro: torch.Tensor) -> None:
    """Test if the AUPRO metric is computed correctly."""
    aupro = AUPRO(fpr_limit=fpr_limit)
    aupro.update(preds, labels)
    computed_aupro = aupro.compute()

    tmp_labels = [label.squeeze().numpy() for label in labels]
    tmp_preds = [pred.squeeze().numpy() for pred in preds]
    ref_aupro = torch.tensor(calculate_au_pro(tmp_labels, tmp_preds, integration_limit=fpr_limit)[0], dtype=torch.float)

    tolerance = 0.001
    assert torch.allclose(computed_aupro, expected_aupro, atol=tolerance)
    assert torch.allclose(computed_aupro, ref_aupro, atol=tolerance)
Test if the AUPRO metric is computed correctly.
tests/unit/metrics/aupro/test_aupro.py