def compute_counts_confs_accs(
    preds: Array,
    probs: Array,
    targets: Array,
    plot: bool = False,
    plot_options: Optional[Dict] = None,
) -> Tuple[jnp.ndarray, jnp.ndarray, jnp.ndarray]:
    """
    Bin the confidence scores (maximum probability) and for each of them compute:
        - the number of inputs;
        - the average confidence score for each bin;
        - the average accuracy over each bin.

    Parameters
    ----------
    preds: Array
        A one-dimensional array of predictions over the data points.
    probs: Array
        A two-dimensional array of class probabilities for each data point.
    targets: Array
        A one-dimensional array of target variables.
    plot: bool
        Whether to plot a reliability diagram.
    plot_options: dict
        Options for the reliability diagram plot; see :func:`~fortuna.plot.plot_reliability_diagram`.

    Returns
    -------
    Tuple[jnp.ndarray, jnp.ndarray, jnp.ndarray]
        Number of inputs per bin, average confidence score per bin and average accuracy per bin.
    """
    if probs.ndim == 2:
        probs = probs.max(-1)
    thresholds = jnp.linspace(1 / len(probs), 1, 10)
    probs = jnp.array(probs)
    indices = [jnp.where(probs <= thresholds[0])[0]]
    indices += [
        jnp.where((probs <= thresholds[i]) & (probs > thresholds[i - 1]))[0]
        for i in range(1, len(thresholds))
    ]
    counts = jnp.array([len(idx) for idx in indices])

    diff = targets - preds
    accs = jnp.array([jnp.nan_to_num(jnp.mean(diff[idx] == 0)) for idx in indices])
    confs = jnp.array([jnp.nan_to_num(jnp.mean(probs[idx])) for idx in indices])

    if plot:
        idx = confs != 0
        if plot_options is None:
            plot_options = dict()
        plot_reliability_diagram(accs[idx], confs[idx], **plot_options)

    return counts, confs, accs

    Bin the confidence scores (maximum probability) and for each of them compute:
        - the number of inputs;
        - the average confidence score for each bin;
        - the average accuracy over each bin.

    Parameters
    ----------
    preds: Array
        A one-dimensional array of predictions over the data points.
    probs: Array
        A two-dimensional array of class probabilities for each data point.
    targets: Array
        A one-dimensional array of target variables.
    plot: bool
        Whether to plot a reliability diagram.
    plot_options: dict
        Options for the reliability diagram plot; see :func:`~fortuna.plot.plot_reliability_diagram`.

    Returns
    -------
    Tuple[jnp.ndarray, jnp.ndarray, jnp.ndarray]
        Number of inputs per bin, average confidence score per bin and average accuracy per bin.
    
fortuna/metric/classification.py