def eval_metric_from_binary_prediction(
    anomalies: Union[TimeSeries, Sequence[TimeSeries]],
    pred_anomalies: Union[TimeSeries, Sequence[TimeSeries]],
    window: Union[int, Sequence[int]] = 1,
    metric: Literal["recall", "precision", "f1", "accuracy"] = "recall",
) -> Union[float, Sequence[float], Sequence[Sequence[float]]]:
    """Computes a score/metric between predicted anomalies against true anomalies.

    `pred_anomalies` and `anomalies` must have:

        - identical dimensions (number of time steps and number of components/columns),
        - binary values belonging to the two classes (`1` if it is an anomaly and `0` if not)

    If one series is given for `anomalies` and `pred_anomalies` contains more than
    one series, the function will consider `anomalies` as the true anomalies for
    all scores in `pred_scores`.

    Parameters
    ----------
    anomalies
        The (sequence of) ground truth binary anomaly series (`1` if it is an anomaly and `0` if not).
    pred_anomalies
        The (sequence of) predicted binary anomaly series.
    window
        Integer value indicating the number of past samples each point represents in the `pred_scores`.
        The parameter will be used to transform `anomalies`.
        If a list of integers, the length must match the number of series in `pred_scores`.
        If an integer, the value will be used for every series in `pred_scores` and `anomalies`.
    metric
        The name of the metric function to use. Must be one of "recall", "precision", "f1", and "accuracy".
        Default: "recall".

    Returns
    -------
    float
        A single score for univariate `pred_anomalies` series (with only one component/column).
    Sequence[float]
        A sequence (list) of scores for:

        - multivariate `pred_anomalies` series (multiple components). Gives a score for each component.
        - a sequence (list) of univariate `pred_anomalies` series. Gives a score for each series.
    Sequence[Sequence[float]]
        A sequence of sequences of scores for a sequence of multivariate `pred_anomalies` series.
        Gives a score for each series (outer sequence) and component (inner sequence).
    """
    return _eval_metric(
        anomalies=anomalies,
        pred_series=pred_anomalies,
        window=window,
        metric=metric,
        pred_is_binary=True,
    )
Computes a score/metric between predicted anomalies against true anomalies.

    `pred_anomalies` and `anomalies` must have:

        - identical dimensions (number of time steps and number of components/columns),
        - binary values belonging to the two classes (`1` if it is an anomaly and `0` if not)

    If one series is given for `anomalies` and `pred_anomalies` contains more than
    one series, the function will consider `anomalies` as the true anomalies for
    all scores in `pred_scores`.

    Parameters
    ----------
    anomalies
        The (sequence of) ground truth binary anomaly series (`1` if it is an anomaly and `0` if not).
    pred_anomalies
        The (sequence of) predicted binary anomaly series.
    window
        Integer value indicating the number of past samples each point represents in the `pred_scores`.
        The parameter will be used to transform `anomalies`.
        If a list of integers, the length must match the number of series in `pred_scores`.
        If an integer, the value will be used for every series in `pred_scores` and `anomalies`.
    metric
        The name of the metric function to use. Must be one of "recall", "precision", "f1", and "accuracy".
        Default: "recall".

    Returns
    -------
    float
        A single score for univariate `pred_anomalies` series (with only one component/column).
    Sequence[float]
        A sequence (list) of scores for:

        - multivariate `pred_anomalies` series (multiple components). Gives a score for each component.
        - a sequence (list) of univariate `pred_anomalies` series. Gives a score for each series.
    Sequence[Sequence[float]]
        A sequence of sequences of scores for a sequence of multivariate `pred_anomalies` series.
        Gives a score for each series (outer sequence) and component (inner sequence).
    
darts/ad/utils.py