def explained_variance(preds, targets):
    """
    Calculate the explained variance between predictions and targets

    Args:
        preds(Tensor): predictions
        targets(Tensor): ground truth

    Returns:
        Var: explained variance
    """
    return (1 - (targets - preds).var() / targets.var()).asnumpy()