docstr: Compare embedding Features with the memory bank to get Nearest Neighbours distance
          
docstr_tok: ["Compare","embedding","Features","with","the","memory","bank","to","get","Nearest","Neighbours","distance"]
code: def nearest_neighbors(self, embedding, n_neighbors: int = 9):
      """Compare embedding Features with the memory bank to get Nearest Neighbours distance"""
      B, HW, C = embedding.shape
      n_coreset = self.memory_bank.shape[0]
      distances = []  # paddle.zeros((B, HW, n_coreset))
      for i in range(B):
          distances.append(
              cdist(embedding[i, :, :], self.memory_bank, p=2.0)
          )  # euclidean norm
      distances = paddle.stack(distances, 0)
      distances, _ = distances.topk(
          k=n_neighbors, axis=-1, largest=False
      )
      return distances
  
imports: import numpy
  from tqdm import tqdm
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from paddle.vision.models.resnet import resnet18, resnet50, wide_resnet50_2
  from scipy.ndimage import gaussian_filter
  from qinspector.cvlib.workspace import register
  from qinspector.uad.utils.utils import cdist, cholesky_inverse, mahalanobis, mahalanobis_einsum, orthogonal, svd_orthogonal
  from qinspector.uad.utils.k_center_greedy import KCenterGreedy
label_desc: Use image node_id 12 for calling the PatchCore obj's underlying member method code with example usage: obj.nearest_neighbors(embedding, n_neighbors) and returns: distances