Solved by mariosasko in post #2 
              
              
                I assume you meant PyTorch, not Python. For pdist see torch.nn.functional.pdist and for Pearson correlation check out this issue.