Hi, I compute the pairwise distance between the points. Let say, i have
x = torch.randn(128, 2048)
y = x
m = len(x)
dists #  torch.Size([128, 128])

I want to find the closest neighbor to a given point. I managed to do it using numpy.
dists = dists.numpy()
ind = np.unravel_index(np.argsort(dists, axis=None), dists.shape)
idx1 = ind[0]
idx2 = ind[1]

Thus, the closest point to x[idx1[0]] is the point at x[idx2[0]]. How can I do this in pytorch directly?
Thank you.