Hope I’m understanding your issue correctly.
Lets’s say the vectors that you want to take pairwise distances are in a tensor A of shape (N, D), where N is number of vectors and D is the dim. Then we can create two tensors, of shape (N, N, D). For the first tensor B, B[i][j] = A[i] for 0 <= i < N, and for the second tensor C, C[j][i] = A[i]. Then we can view these two tensors as (NxN, D) tensors and do use the pairwise distance module. This probably isn’t the most efficient way, but doesn’t require much addition coding on your part.
https://pytorch.org/docs/master/_modules/torch/nn/modules/distance.html#PairwiseDistance 556