def test_r2_squared_update(
    outputs_list: Iterable[torch.Tensor],
    targets_list: Iterable[torch.Tensor],
    true_values: Dict[str, torch.Tensor],
):
    """
    Test r2 squared metric computation

    Args:
        outputs_list: list of outputs
        targets_list: list of targets
        true_values: true metric values
    """
    metric = R2Squared()
    for outputs, targets in zip(outputs_list, targets_list):
        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 computation

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