docstr: Computes the score of `x`
  
  Parameters
  ----------
  x
      The tensor of instances. First dimension corresponds to batch.
  
  Returns
  -------
  Tensor of scores for each element in `x`.
  
  Raises
  ------
  NotFittedError
      If called before detector has been fit.
docstr_tok: ["Computes","the","score","of","`","x","`","Parameters","--","--","--","--","--","x","The","tensor","of","instances",".","First","dimension","corresponds","to","batch",".","Returns","--","--","--","-","Tensor","of","scores","for","each","element","in","`","x","`",".","Raises","--","--","--","NotFittedError","If","called","before","detector","has","been","fit","."]
code: def score(self, x: torch.Tensor) -> torch.Tensor:
      """Computes the score of `x`
  
      Parameters
      ----------
      x
          The tensor of instances. First dimension corresponds to batch.
  
      Returns
      -------
      Tensor of scores for each element in `x`.
  
      Raises
      ------
      NotFittedError
          If called before detector has been fit.
      """
      self.check_fitted()
      K = (
          -self.kernel(x, self.x_ref)
          if self.kernel is not None
          else torch.cdist(x, self.x_ref)
      )
      bot_k_dists = torch.topk(
          K, int(torch.max(self.ks)), dim=1, largest=False
      )
      all_knn_dists = bot_k_dists.values[:, self.ks - 1]
      return all_knn_dists if self.ensemble else all_knn_dists[:, 0]
  
file_path: alibi-detect/alibi_detect/od/pytorch/knn.py
imports: from typing import Optional, Union, List, Tuple
  import numpy
  import torch
  from alibi_detect.od.pytorch.ensemble import Ensembler
  from alibi_detect.od.pytorch.base import TorchOutlierDetector
  from alibi_detect.utils._types import TorchDeviceType
label_desc: Use image node_id 3 for calling the KNNTorch obj's underlying member method code with example usage: obj.score(x) and returns: unknown