class_docstr: Kozachenko-Leonenko entropic loss regularizer from Sablayrolles et al. - 2018 - Spreading vectors for similarity search
docstr: Pairwise nearest neighbors for L2-normalized vectors.
  Uses Torch rather than Faiss to remain on GPU.
docstr_tok: ["Pairwise","nearest","neighbors","for","L2-normalized","vectors",".","Uses","Torch","rather","than","Faiss","to","remain","on","GPU","."]
code: def pairwise_NNs_inner(self, x):
      """
      Pairwise nearest neighbors for L2-normalized vectors.
      Uses Torch rather than Faiss to remain on GPU.
      """
      # parwise dot products (= inverse distance)
      dots = torch.mm(x, x.t())
      n = x.shape[0]
      dots.view(-1)[:: (n + 1)].fill_(
          -1
      )  # Trick to fill diagonal with -1
      # max inner prod -> min distance
      _, I = torch.max(dots, dim=1)  # noqa: E741
      return I
  
file_path: dinov2/dinov2/loss/koleo_loss.py
imports: import logging
  import torch
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 2 for calling the KoLeoLoss obj's underlying member method code with example usage: obj.pairwise_NNs_inner(x) and returns: I