code: def test_fitted_knn_ensemble(aggregator, normalizer):
      knn_detector = KNN(
          k=[8, 9, 10], aggregator=aggregator(), normalizer=normalizer()
      )
      x_ref = np.random.randn(100, 2)
      knn_detector.fit(x_ref)
      x = np.array([[0, 10], [0, 0.1]])
  
      # test ensemble raises ThresholdNotInferredError if only fit and not threshold inferred and
      # the normalizer is not None.
      if normalizer() is not None:
          with pytest.raises(ThresholdNotInferredError):
              knn_detector.predict(x)
      else:
          knn_detector.predict(x)
  
file_path: alibi-detect/alibi_detect/od/tests/test__knn/test__knn.py
imports: import pytest
  import numpy
  import torch
  from alibi_detect.od._knn import KNN
  from alibi_detect.od.pytorch.ensemble import AverageAggregator, TopKAggregator, MaxAggregator, MinAggregator, ShiftAndScaleNormalizer, PValNormalizer
  from alibi_detect.exceptions import NotFittedError, ThresholdNotInferredError
  from sklearn.datasets import make_moons
label_desc: Use image node_id 8 for calling a global function with example usage: test_fitted_knn_ensemble(aggregator, normalizer) without return types