code: def test_fitted_knn_ensemble_score():
      """
      Test fitted but not threshold inferred ensemble detectors correctly raise an error when calling
      the predict method. This is because the ensembler is fit in the infer_threshold method.
      """
      knn_detector = KNN(k=[10, 14, 18])
      x_ref = np.random.randn(100, 2)
      knn_detector.fit(x_ref)
      x = np.array([[0, 10], [0.1, 0]])
      with pytest.raises(ThresholdNotInferredError):
          knn_detector.predict(x)
  
      with pytest.raises(ThresholdNotInferredError):
          knn_detector.score(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 4 for calling a global function with example usage: test_fitted_knn_ensemble_score() without return types