def loss(y_pred, y_true, metric):
    """
    Loss function given by a Riemannian metric,
    expressed as the squared geodesic distance between the prediction
    and the ground truth.
    """
    loss = metric.squared_dist(y_pred, y_true)
    return loss