import torch


def compute_brier_score(y_pred, y_true):
    """Brier score implementation follows 
    https://papers.nips.cc/paper/7219-simple-and-scalable-predictive-uncertainty-estimation-using-deep-ensembles.pdf.
    The lower the Brier score is for a set of predictions, the better the predictions are calibrated."""        
        
    brier_score = torch.mean(torch.mean(torch.mean((y_true-y_pred)**2, dim=3),dim=2), dim=1)
    return brier_score