code: def test_knn_torch_backend():
      """
      Test the knn torch backend can be correctly initialized, fit and used to
      predict outliers.
      """
  
      knn_torch = KNNTorch(k=5)
      x = torch.randn((3, 10)) * torch.tensor([[1], [1], [100]])
      x_ref = torch.randn((1024, 10))
      knn_torch.fit(x_ref)
      outputs = knn_torch.predict(x)
      assert outputs.instance_score.shape == (3,)
      assert outputs.is_outlier is None
      assert outputs.p_value is None
      scores = knn_torch.score(x)
      assert torch.all(scores == outputs.instance_score)
  
      knn_torch.infer_threshold(x_ref, 0.1)
      outputs = knn_torch.predict(x)
      assert torch.all(
          outputs.is_outlier == torch.tensor([False, False, True])
      )
      assert torch.all(
          knn_torch(x) == torch.tensor([False, False, True])
      )
  
file_path: alibi-detect/alibi_detect/od/tests/test__knn/test__knn_backend.py
imports: import pytest
  import torch
  from alibi_detect.od.pytorch.knn import KNNTorch
  from alibi_detect.utils.pytorch.kernels import GaussianRBF
  from alibi_detect.od.pytorch.ensemble import Ensembler, PValNormalizer, AverageAggregator
  from alibi_detect.exceptions import NotFittedError, ThresholdNotInferredError
label_desc: Use image node_id 2 for calling a global function with example usage: test_knn_torch_backend() without return types