I have a tensor say,
a = torch.random(10,2)

I would like to create a  knn graph of this tensor a using torch such that it returns me k indices and distances, for each row of this a tensor. That is to say distances.shape is [10,k] and indices.shape is [10,k]
Basically I look  to do something like this 8 (section 1.6.1.1. Finding the Nearest Neighbors) using torch.  It is not very evident to me how to do this?