def METHOD_NAME(metric_class=R2Score):
    """Test that error is raised if too few samples are provided."""
    metric = metric_class()
    with pytest.raises(ValueError, match="Needs at least two samples to calculate r2 score."):
        metric(torch.randn(1), torch.randn(1))
    metric.reset()
    # calling update twice should still work
    metric.update(torch.randn(1), torch.randn(1))
    metric.update(torch.randn(1), torch.randn(1))
    assert metric.compute()