class_docstr: Grouped KNN density estimator.
  
  Keeps track of the group (e.g. video id) from which the features were sampled for normalization purposes.
  
  Args:
      n_neighbors (int): Number of neighbors used in KNN search.
docstr: Perform the KNN search.
  
  Args:
      feature_bank (Tensor): Feature bank used for KNN search.
      features (Ternsor): Input features.
      n_neighbors (int): Number of neighbors used in KNN search.
  Returns:
      Tensor: Distances between the input features and their K nearest neighbors in the feature bank.
code: def _nearest_neighbors(
      feature_bank: Tensor, features: Tensor, n_neighbors: int = 1
  ):
      """Perform the KNN search.
  
      Args:
          feature_bank (Tensor): Feature bank used for KNN search.
          features (Ternsor): Input features.
          n_neighbors (int): Number of neighbors used in KNN search.
      Returns:
          Tensor: Distances between the input features and their K nearest neighbors in the feature bank.
      """
      distances = torch.cdist(
          features, feature_bank, p=2.0
      )  # euclidean norm
      if n_neighbors == 1:
          # when n_neighbors is 1, speed up computation by using min instead of topk
          distances, _ = distances.min(1)
          return distances.unsqueeze(1)
      distances, _ = distances.topk(k=n_neighbors, largest=False, dim=1)
      return distances
  
imports: from __future__ import annotations
  from abc import ABC, abstractmethod
  from typing import Any
  import torch
  from sklearn.mixture import GaussianMixture
  from torch import Tensor, nn
  from anomalib.models.ai_vad.features import FeatureType
  from anomalib.utils.metrics.min_max import MinMax
label_desc: Use image node_id 5 for calling the GroupedKNNEstimator obj's underlying member method code with example usage: obj._nearest_neighbors(feature_bank, features, n_neighbors) and returns: distances, distances