I am trying to implement a function similar to Scipy.spactial.distance.pdist in PyTorch for computing correlation. I can get the values for the symmetric matrix of pair comparison, but I want to get a vector form similar to squareform(Matrix)=vec. I noticed that in PyTorch the function pdist does a similar indexing  going from NN to N(N-1)/2 vector. now I am trying to figure it where and how torch.nn.functional.pdist implement this indexing.