def test_compute() -> None:
    """Test computation of the min and max values after updates."""
    metric = _MinMax()
    batch1 = torch.tensor([1.0, 2.0])
    batch2 = torch.tensor([-1.0, 0.0])

    metric.update(batch1)
    metric.update(batch2)

    min_val, max_val = metric.compute()

    assert min_val.item() == -1.0, "Computed min should be -1.0."
    assert max_val.item() == 2.0, "Computed max should be 2.0."
Test computation of the min and max values after updates.
tests/unit/metrics/test_min_max.py