def test_f1_max_logits() -> None:
    """Checks if F1Max metric computes the optimal F1 score.

    Test when the preds are in [0, 1]
    """
    metric = F1Max()

    preds = torch.tensor([0.1, 0.5, 0.9, 1.0])
    labels = torch.tensor([0, 1, 1, 1])

    metric.update(preds, labels)
    assert metric.compute() == 1.0
    assert metric.threshold == 0.5

    metric.reset()
    preds = torch.tensor([0.1, 0.5, 0.9, 0.1])
    metric.update(preds, labels)
    # f1_score = (3 / 2) / (7 / 4 + 1e-10)  # noqa: ERA001
    assert metric.compute().round(decimals=4) == torch.tensor(0.8571)
    assert metric.threshold == 0.1
Checks if F1Max metric computes the optimal F1 score.

    Test when the preds are in [0, 1]
    
tests/unit/metrics/test_f1_max.py