code: def test_eval_accuracy(self):
      am1 = ForecastingAnomalyModel(
          model=RegressionModel(lags=10), scorer=NormScorer()
      )
      am1.fit(self.train, allow_model_training=True)
  
      am2 = FilteringAnomalyModel(
          model=MovingAverageFilter(window=20), scorer=NormScorer()
      )
  
      am3 = ForecastingAnomalyModel(
          model=RegressionModel(lags=10),
          scorer=[NormScorer(), WassersteinScorer()],
      )
      am3.fit(self.train, allow_model_training=True)
  
      am4 = FilteringAnomalyModel(
          model=MovingAverageFilter(window=20),
          scorer=[NormScorer(), WassersteinScorer()],
      )
      am4.fit(self.train)
  
      for am in [am1, am2, am3, am4]:
          # if the anomaly_model have scorers that have the parameter univariate_scorer set to True,
          # 'actual_anomalies' must have widths of 1
          if am.univariate_scoring:
              with pytest.raises(ValueError):
                  am.eval_accuracy(
                      actual_anomalies=self.mts_anomalies,
                      series=self.test,
                  )
              with pytest.raises(ValueError):
                  am.eval_accuracy(
                      actual_anomalies=self.mts_anomalies,
                      series=self.mts_test,
                  )
              with pytest.raises(ValueError):
                  am.eval_accuracy(
                      actual_anomalies=[
                          self.anomalies,
                          self.mts_anomalies,
                      ],
                      series=[self.test, self.mts_test],
                  )
  
          # 'metric' must be str and "AUC_ROC" or "AUC_PR"
          with pytest.raises(ValueError):
              am.eval_accuracy(
                  actual_anomalies=self.anomalies,
                  series=self.test,
                  metric=1,
              )
          with pytest.raises(ValueError):
              am.eval_accuracy(
                  actual_anomalies=self.anomalies,
                  series=self.test,
                  metric="auc_roc",
              )
          with pytest.raises(TypeError):
              am.eval_accuracy(
                  actual_anomalies=self.anomalies,
                  series=self.test,
                  metric=["AUC_ROC"],
              )
  
          # 'actual_anomalies' must be binary
          with pytest.raises(ValueError):
              am.eval_accuracy(
                  actual_anomalies=self.test, series=self.test
              )
  
          # 'actual_anomalies' must contain anomalies (at least one)
          with pytest.raises(ValueError):
              am.eval_accuracy(
                  actual_anomalies=self.only_0_anomalies,
                  series=self.test,
              )
  
          # 'actual_anomalies' cannot contain only anomalies
          with pytest.raises(ValueError):
              am.eval_accuracy(
                  actual_anomalies=self.only_1_anomalies,
                  series=self.test,
              )
  
          # 'actual_anomalies' must match the number of series
          with pytest.raises(ValueError):
              am.eval_accuracy(
                  actual_anomalies=self.anomalies,
                  series=[self.test, self.test],
              )
          with pytest.raises(ValueError):
              am.eval_accuracy(
                  actual_anomalies=[self.anomalies, self.anomalies],
                  series=self.test,
              )
  
          # 'actual_anomalies' must have non empty intersection with 'series'
          with pytest.raises(ValueError):
              am.eval_accuracy(
                  actual_anomalies=self.anomalies[:20],
                  series=self.test[30:],
              )
          with pytest.raises(ValueError):
              am.eval_accuracy(
                  actual_anomalies=[
                      self.anomalies,
                      self.anomalies[:20],
                  ],
                  series=[self.test, self.test[40:]],
              )
  
          # Check input type
          # 'actual_anomalies' and 'series' must be of same length
          with pytest.raises(ValueError):
              am.eval_accuracy([self.anomalies], [self.test, self.test])
          with pytest.raises(ValueError):
              am.eval_accuracy(self.anomalies, [self.test, self.test])
          with pytest.raises(ValueError):
              am.eval_accuracy(
                  [self.anomalies, self.anomalies], [self.test]
              )
          with pytest.raises(ValueError):
              am.eval_accuracy(
                  [self.anomalies, self.anomalies], self.test
              )
  
          # 'actual_anomalies' and 'series' must be of type Timeseries
          with pytest.raises(ValueError):
              am.eval_accuracy([self.anomalies], [2, 3, 4])
          with pytest.raises(ValueError):
              am.eval_accuracy([self.anomalies], "str")
          with pytest.raises(ValueError):
              am.eval_accuracy([2, 3, 4], self.test)
          with pytest.raises(ValueError):
              am.eval_accuracy("str", self.test)
          with pytest.raises(ValueError):
              am.eval_accuracy(
                  [self.anomalies, self.anomalies],
                  [self.test, [3, 2, 1]],
              )
          with pytest.raises(ValueError):
              am.eval_accuracy(
                  [self.anomalies, [3, 2, 1]], [self.test, self.test]
              )
  
          # Check return types
          # Check if return type is float when input is a series
          assert isinstance(
              am.eval_accuracy(self.anomalies, self.test),
              Dict,
          )
  
          # Check if return type is Sequence when input is a Sequence of series
          assert isinstance(
              am.eval_accuracy(self.anomalies, [self.test]),
              Sequence,
          )
          assert isinstance(
              am.eval_accuracy(
                  [self.anomalies, self.anomalies],
                  [self.test, self.test],
              ),
              Sequence,
          )
  
imports: from typing import Dict, Sequence, Tuple
  import numpy
  import pandas
  import pytest
  from pyod.models.knn import KNN
  from darts import TimeSeries
  from darts.ad import AndAggregator
  from darts.ad import EnsembleSklearnAggregator
  from darts.ad import OrAggregator
  from darts.ad import QuantileDetector
  from darts.ad import ThresholdDetector
  from darts.ad import CauchyNLLScorer
  from darts.ad import DifferenceScorer
  from darts.ad import ExponentialNLLScorer, FilteringAnomalyModel, ForecastingAnomalyModel, GammaNLLScorer, GaussianNLLScorer, KMeansScorer, LaplaceNLLScorer, NormScorer, PoissonNLLScorer, PyODScorer, WassersteinScorer
  from darts.ad.utils import eval_accuracy_from_scores, show_anomalies_from_scores
  from darts.models import MovingAverageFilter, NaiveSeasonal, RegressionModel
label_desc: Use image node_id 7 for calling the TestADAnomalyModel obj's underlying member method code with example usage: obj.test_eval_accuracy() without return types