def brier_score(probs: Array, targets: Union[TargetsLoader, Array]) -> jnp.ndarray:
    """
    Brier score (see `Brier, 1950 <https://web.archive.org/web/20171023012737/
    https://docs.lib.noaa.gov/rescue/mwr/078/mwr-078-01-0001.pdf>`__). This can be used for both binary and multi-class
    classification.

    Parameters
    ----------
    probs: Array
        A one- or two-dimensional array of class probabilities for each data point.
    targets: Array
        A one-dimensional array of target variables.

    Returns
    -------
    jnp.ndarray
        The Brier score.
    """
    if probs.ndim > 2:
        raise ValueError("`probs` can be at most 2 dimensional.")
    if type(targets) == TargetsLoader:
        targets = targets.to_array_targets()
    if probs.ndim > 1:
        targets = jax.nn.one_hot(targets, probs.shape[-1])
        return jnp.mean(jnp.sum((probs - targets) ** 2, axis=-1))
    return jnp.mean((probs - targets) ** 2)

    Brier score (see `Brier, 1950 <https://web.archive.org/web/20171023012737/
    https://docs.lib.noaa.gov/rescue/mwr/078/mwr-078-01-0001.pdf>`__). This can be used for both binary and multi-class
    classification.

    Parameters
    ----------
    probs: Array
        A one- or two-dimensional array of class probabilities for each data point.
    targets: Array
        A one-dimensional array of target variables.

    Returns
    -------
    jnp.ndarray
        The Brier score.
    
fortuna/metric/classification.py