code: def test_univariate_kmeans(self):
      # univariate example
  
      np.random.seed(40)
  
      # create the train set
      np_width1 = np.random.choice(a=[0, 1], size=100, p=[0.5, 0.5])
      np_width2 = (np_width1 == 0).astype(float)
      KMeans_mts_train = TimeSeries.from_values(
          np.dstack((np_width1, np_width2))[0],
          columns=["component 1", "component 2"],
      )
  
      # create the test set
      # inject anomalies in the test timeseries
      np.random.seed(3)
      np_width1 = np.random.choice(a=[0, 1], size=100, p=[0.5, 0.5])
      np_width2 = (np_width1 == 0).astype(int)
  
      # 2 anomalies per type
      # type 1: random values for only one width
      np_width1[20:21] = 2
      np_width2[30:32] = 2
  
      # type 2: shift both widths values (+/- 1 for both widths)
      np_width1[45:47] = np_width1[45:47] + 1
      np_width2[45:47] = np_width2[45:47] + 1
      np_width1[60:64] = np_width1[65:69] - 1
      np_width2[60:64] = np_width2[65:69] - 1
  
      # type 3: switch one state to another for only one width (1 to 0 for one width)
      np_width1[75:82] = (np_width1[75:82] != 1).astype(int)
      np_width2[90:96] = (np_width2[90:96] != 1).astype(int)
  
      KMeans_mts_test = TimeSeries.from_values(
          np.dstack((np_width1, np_width2))[0],
          columns=["component 1", "component 2"],
      )
  
      # create the anomaly series
      anomalies_index = [
          20,
          30,
          31,
          45,
          46,
          60,
          61,
          62,
          63,
          75,
          76,
          77,
          78,
          79,
          80,
          81,
          90,
          91,
          92,
          93,
          94,
          95,
      ]
      np_anomalies = np.zeros(len(KMeans_mts_test))
      np_anomalies[anomalies_index] = 1
      KMeans_mts_anomalies = TimeSeries.from_times_and_values(
          KMeans_mts_test.time_index,
          np_anomalies,
          columns=["is_anomaly"],
      )
  
      kmeans_scorer = KMeansScorer(k=2, window=1, component_wise=False)
      kmeans_scorer.fit(KMeans_mts_train)
  
      metric_AUC_ROC = kmeans_scorer.eval_accuracy(
          KMeans_mts_anomalies, KMeans_mts_test, metric="AUC_ROC"
      )
      metric_AUC_PR = kmeans_scorer.eval_accuracy(
          KMeans_mts_anomalies, KMeans_mts_test, metric="AUC_PR"
      )
  
      assert metric_AUC_ROC == 1.0
      assert metric_AUC_PR == 1.0
  
imports: from typing import Sequence
  import numpy
  import pytest
  import sklearn
  from pyod.models.knn import KNN
  from scipy.stats import cauchy, expon, gamma, laplace, norm, poisson
  from darts import TimeSeries
  from darts.ad.scorers import CauchyNLLScorer
  from darts.ad.scorers import DifferenceScorer
  from darts.ad.scorers import ExponentialNLLScorer, GammaNLLScorer, GaussianNLLScorer, KMeansScorer, LaplaceNLLScorer
  from darts.ad.scorers import NormScorer
  from darts.ad.scorers import PoissonNLLScorer, PyODScorer, WassersteinScorer
  from darts.models import MovingAverageFilter
label_desc: Use image node_id 12 for calling the TestADAnomalyScorer obj's underlying member method code with example usage: obj.test_univariate_kmeans() without return types