If you have a matrix of size 2000 x 1000 and you won’t the outer product of the i-th row, you can use torch.einsum.
So, for example having a matrix that’s shape [i,j] doing torch.einsum("ij->ijj", a) will return the outer product for you.