code: def test_GammaNLLScorer(self):
      # window parameter
      # window must be int
      with pytest.raises(ValueError):
          GammaNLLScorer(window=True)
      with pytest.raises(ValueError):
          GammaNLLScorer(window="string")
      # window must be non negative
      with pytest.raises(ValueError):
          GammaNLLScorer(window=-1)
      # window must be different from 0
      with pytest.raises(ValueError):
          GammaNLLScorer(window=0)
  
      scorer = GammaNLLScorer(window=101)
      # window must be smaller than the input of score_from_prediction()
      with pytest.raises(ValueError):
          scorer.score_from_prediction(
              actual_series=self.test, pred_series=self.probabilistic
          )  # len(self.test)=100
  
      np.random.seed(4)
      scorer = GammaNLLScorer()
  
      # test 1 univariate (len=1 and window=1)
      gamma_samples_1 = np.random.gamma(shape=2, scale=2, size=10000)
      distribution_series = TimeSeries.from_values(
          gamma_samples_1.reshape(1, 1, -1)
      )
      actual_series = TimeSeries.from_values(np.array([3]))
      value_test1 = (
          scorer.score_from_prediction(
              actual_series, distribution_series
          )
          .all_values()
          .flatten()[0]
      )
  
      # check if value_test1 is the - log likelihood
      assert abs(value_test1 + np.log(gamma.pdf(3, 2, scale=2))) < 1e-01
  
      # test 2 univariate (len=1 and window=1)
      gamma_samples_2 = np.random.gamma(2, scale=2, size=10000)
      distribution_series = TimeSeries.from_values(
          gamma_samples_2.reshape(1, 1, -1)
      )
      actual_series = TimeSeries.from_values(np.array([10]))
      value_test2 = (
          scorer.score_from_prediction(
              actual_series, distribution_series
          )
          .all_values()
          .flatten()[0]
      )
  
      # check if value_test2 is the - log likelihood
      assert (
          abs(value_test2 + np.log(gamma.pdf(10, 2, scale=2))) < 1e-01
      )
  
      # test window univariate (len=2 and window=2)
      distribution_series = TimeSeries.from_values(
          np.array(
              [
                  gamma_samples_1.reshape(1, -1),
                  gamma_samples_2.reshape(1, -1),
              ]
          )
      )
      actual_series = TimeSeries.from_values(np.array([3, 10]))
      value_window = scorer.score_from_prediction(
          actual_series, distribution_series
      )
  
      # check length
      assert len(value_window) == 2
      # check width
      assert value_window.width == 1
  
      # check equal value_test1 and value_test2
      assert value_window.all_values().flatten()[0] == value_test1
      assert value_window.all_values().flatten()[1] == value_test2
  
      scorer = GammaNLLScorer(window=2)
      # check avg of two values
      assert (
          scorer.score_from_prediction(
              actual_series, distribution_series
          )
          .all_values()
          .flatten()[0]
          == (value_test1 + value_test2) / 2
      )
  
      # test window multivariate (n_samples=2, len=1, window=1)
      scorer = GammaNLLScorer(window=1)
      distribution_series = TimeSeries.from_values(
          np.array([gamma_samples_1, gamma_samples_2]).reshape(1, 2, -1)
      )
      actual_series = TimeSeries.from_values(
          np.array([3, 10]).reshape(1, -1)
      )
      value_multivariate = scorer.score_from_prediction(
          actual_series, distribution_series
      )
  
      # check length
      assert len(value_multivariate) == 1
      # check width
      assert value_multivariate.width == 2
  
      # check equal value_test1 and value_test2
      assert value_multivariate.all_values().flatten()[0] == value_test1
      assert value_multivariate.all_values().flatten()[1] == value_test2
  
      # test window multivariate (n_samples=2, len=2, window=1 and 2)
      scorer_w1 = GammaNLLScorer(window=1)
      scorer_w2 = GammaNLLScorer(window=2)
  
      gamma_samples_3 = np.random.gamma(2, scale=2, size=10000)
      gamma_samples_4 = np.random.gamma(2, scale=2, size=10000)
  
      distribution_series = TimeSeries.from_values(
          np.array(
              [
                  gamma_samples_1,
                  gamma_samples_2,
                  gamma_samples_3,
                  gamma_samples_4,
              ]
          ).reshape(2, 2, -1)
      )
  
      actual_series = TimeSeries.from_values(
          np.array([1.5, 2, 0.5, 0.9]).reshape(2, -1)
      )
  
      score_w1 = scorer_w1.score_from_prediction(
          actual_series, distribution_series
      )
      score_w2 = scorer_w2.score_from_prediction(
          actual_series, distribution_series
      )
  
      # check length
      assert len(score_w1) == 2
      assert len(score_w2) == 1
      # check width
      assert score_w1.width == 2
      assert score_w2.width == 2
  
      # check values for window=1
      assert (
          abs(
              score_w1.all_values().flatten()[0]
              + np.log(gamma.pdf(1.5, 2, scale=2))
          )
          < 1e-01
      )
      assert (
          abs(
              score_w1.all_values().flatten()[1]
              + np.log(gamma.pdf(2, 2, scale=2))
          )
          < 1e-01
      )
      assert (
          abs(
              score_w1.all_values().flatten()[2]
              + np.log(gamma.pdf(0.5, 2, scale=2))
          )
          < 1e-01
      )
      assert (
          abs(
              score_w1.all_values().flatten()[3]
              + np.log(gamma.pdf(0.9, 2, scale=2))
          )
          < 1e-01
      )
  
      # check values for window=2 (must be equal to the mean of the past 2 values)
      assert (
          abs(
              score_w2.all_values().flatten()[0]
              - (
                  -np.log(gamma.pdf(1.5, 2, scale=2))
                  - np.log(gamma.pdf(0.5, 2, scale=2))
              )
              / 2
          )
          < 1e-01
      )
      assert (
          abs(
              score_w2.all_values().flatten()[1]
              - (
                  -np.log(gamma.pdf(2, 2, scale=2))
                  - np.log(gamma.pdf(0.9, 2, scale=2))
              )
              / 2
          )
          < 1e-01
      )
  
      assert scorer.is_probabilistic
  
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 23 for calling the TestADAnomalyScorer obj's underlying member method code with example usage: obj.test_GammaNLLScorer() without return types