Matrix of Dot Products

Given some tensor of input samples of the shape (n_samples, n_features), what’s the best way to calculate a matrix with the shape (n_samples, n_samples) where the element e_{i,j} contains the dot product of the samples with the indices i and j?

I might misunderstand the question, but would

x = torch.randn(5, 10)
torch.matmul(x, x.t())