def eval_metric(
        self,
        anomalies: Union[TimeSeries, Sequence[TimeSeries]],
        series: Union[TimeSeries, Sequence[TimeSeries]],
        metric: Literal["AUC_ROC", "AUC_PR"] = "AUC_ROC",
        **kwargs,
    ) -> Union[
        dict[str, float],
        dict[str, Sequence[float]],
        Sequence[dict[str, float]],
        Sequence[dict[str, Sequence[float]]],
    ]:
        """Compute the accuracy of the anomaly scores computed by the model.

        Predicts the `series` with the underlying forecasting/filtering model, and applies the scorer(s) on the
        predicted time series and the given target time series. Returns the score(s) of an agnostic threshold metric,
        based on the anomaly score given by the scorer(s).

        Parameters
        ----------
        anomalies
            The (sequence of) ground truth binary anomaly series (`1` if it is an anomaly and `0` if not).
        series
            The (sequence of) series to predict anomalies on.
        metric
            The name of the metric function to use. Must be one of "AUC_ROC" (Area Under the
            Receiver Operating Characteristic Curve) and "AUC_PR" (Average Precision from scores).
            Default: "AUC_ROC".
        **kwargs
            Additional parameters passed to the `score()` method.

        Returns
        -------
        Dict[str, float]
            A dictionary with the resulting metrics for single univariate `series`, with keys representing the
            anomaly scorer(s), and values representing the metric values.
        Dict[str, Sequence[float]]
            Same as for `Dict[str, float]` but for multivariate `series`, and anomaly scorers that treat series
            components/columns independently (by nature of the scorer or if `component_wise=True`).
        Sequence[Dict[str, float]]
            Same as for `Dict[str, float]` but for a sequence of univariate series.
        Sequence[Dict[str, Sequence[float]]]
            Same as for `Dict[str, float]` but for a sequence of multivariate series.
        """

        def _check_univariate(s: TimeSeries):
            """Checks if `anomalies` contains only univariate series, which
            is required if any of the scorers returns a univariate score.
            """
            if self.scorers_are_univariate and not s.width == 1:
                raise_log(
                    ValueError(
                        f"Anomaly model contains scorer {[s.__str__() for s in self.scorers if s.is_univariate]} "
                        f"that will return a univariate anomaly score series (width=1). Found a multivariate "
                        f"`anomalies`. The evaluation of the accuracy cannot be computed. If applicable, "
                        f"think about setting the scorer parameter `componenet_wise` to True."
                    ),
                    logger=logger,
                )

        called_with_single_series = isinstance(series, TimeSeries)
        # deterministic `series`
        series = _check_input(
            series,
            name="series",
            check_deterministic=True,
        )
        # deterministic, binary anomalies, (possibly univariate)
        anomalies = _check_input(
            anomalies,
            name="anomalies",
            check_deterministic=True,
            check_binary=True,
            extra_checks=_check_univariate,
        )
        _assert_same_length(series, anomalies, "series", "anomalies")

        pred_scores = self.score(series=series, **kwargs)

        # compute metric for anomaly scores
        windows = [s.window for s in self.scorers]

        # create a list of unique names for each scorer that
        # will be used as keys for the dictionary containing
        # the accuracy of each scorer.
        name_scorers = []
        for scorer in self.scorers:
            name = scorer.__str__() + "_w=" + str(scorer.window)

            if name in name_scorers:
                i = 1
                new_name = name + "_" + str(i)
                while new_name in name_scorers:
                    i = i + 1
                    new_name = name + "_" + str(i)
                name = new_name

            name_scorers.append(name)

        metric_vals = []
        for anomalies, scores in zip(anomalies, pred_scores):
            metric_vals.append(
                eval_metric_from_scores(
                    anomalies=anomalies,
                    pred_scores=scores,
                    window=windows,
                    metric=metric,
                )
            )
        metric_vals_pred_scores = [
            dict(zip(name_scorers, scorer_values)) for scorer_values in metric_vals
        ]

        return (
            metric_vals_pred_scores[0]
            if called_with_single_series
            else metric_vals_pred_scores
        )
Compute the accuracy of the anomaly scores computed by the model.

        Predicts the `series` with the underlying forecasting/filtering model, and applies the scorer(s) on the
        predicted time series and the given target time series. Returns the score(s) of an agnostic threshold metric,
        based on the anomaly score given by the scorer(s).

        Parameters
        ----------
        anomalies
            The (sequence of) ground truth binary anomaly series (`1` if it is an anomaly and `0` if not).
        series
            The (sequence of) series to predict anomalies on.
        metric
            The name of the metric function to use. Must be one of "AUC_ROC" (Area Under the
            Receiver Operating Characteristic Curve) and "AUC_PR" (Average Precision from scores).
            Default: "AUC_ROC".
        **kwargs
            Additional parameters passed to the `score()` method.

        Returns
        -------
        Dict[str, float]
            A dictionary with the resulting metrics for single univariate `series`, with keys representing the
            anomaly scorer(s), and values representing the metric values.
        Dict[str, Sequence[float]]
            Same as for `Dict[str, float]` but for multivariate `series`, and anomaly scorers that treat series
            components/columns independently (by nature of the scorer or if `component_wise=True`).
        Sequence[Dict[str, float]]
            Same as for `Dict[str, float]` but for a sequence of univariate series.
        Sequence[Dict[str, Sequence[float]]]
            Same as for `Dict[str, float]` but for a sequence of multivariate series.
        
darts/ad/anomaly_model/anomaly_model.py