def _get_values(
    vals: np.ndarray,
    vals_components: pd.Index,
    actual_components: pd.Index,
    q: Optional[tuple[Sequence[float], Union[Optional[pd.Index]]]] = None,
) -> np.ndarray:
    """
    Returns a deterministic or probabilistic numpy array from the values of a time series of shape
    (times, components, samples / quantiles).
    To extract quantile (sample) values from quantile or stachastic `vals`, use `q`.

    Parameters
    ----------
    vals
        A numpy array with the values of a TimeSeries (actual values or predictions).
    vals_components
        The components of the `vals` TimeSeries.
    actual_components
        The components of the actual TimeSeries.
    q
        Optionally, for stochastic or quantile series/values, return deterministic quantile values.
        If not `None`, must a tuple with (quantile values,
        `None` if `pred_series` is stochastic else the quantile component names).
    """
    # return values as is (times, components, samples)
    if q is None:
        return vals

    q, q_names = q
    if vals.shape[SMPL_AX] == 1:  # deterministic (or quantile components) input
        if q_names is not None:
            # `q_names` are the component names of the predicted quantile parameters
            # we extract the relevant quantile components with shape (times, components * quantiles)
            vals = vals[:, vals_components.get_indexer(q_names)]
            # rearrange into (times, components, quantiles)
            vals = vals.reshape((len(vals), len(actual_components), -1))
        return vals

    # probabilistic input
    # compute multiple quantiles for all times and components; with shape: (quantiles, times, components)
    out = np.quantile(vals, q, axis=SMPL_AX)
    # rearrange into (times, components, quantiles)
    return out.transpose((1, 2, 0))

    Returns a deterministic or probabilistic numpy array from the values of a time series of shape
    (times, components, samples / quantiles).
    To extract quantile (sample) values from quantile or stachastic `vals`, use `q`.

    Parameters
    ----------
    vals
        A numpy array with the values of a TimeSeries (actual values or predictions).
    vals_components
        The components of the `vals` TimeSeries.
    actual_components
        The components of the actual TimeSeries.
    q
        Optionally, for stochastic or quantile series/values, return deterministic quantile values.
        If not `None`, must a tuple with (quantile values,
        `None` if `pred_series` is stochastic else the quantile component names).
    
darts/metrics/metrics.py