def test_r2_squared(
    outputs: torch.Tensor,
    targets: torch.Tensor,
    true_values: Dict[str, torch.Tensor],
) -> None:
    """
    Test r2 squared metric

    Args:
        outputs: tensor of outputs
        targets: tensor of targets
        true_values: true metric values
    """
    metric = R2Squared()
    metric.update(y_pred=outputs, y_true=targets)
    metrics = metric.compute_key_value()
    for key in true_values.keys():
        assert torch.isclose(true_values[key], metrics[key])

    Test r2 squared metric

    Args:
        outputs: tensor of outputs
        targets: tensor of targets
        true_values: true metric values
    
tests/catalyst/metrics/test_r2squared.py