Is there a way to efficiently, in a vectorized manner, compute the combinations along each rows of a 2D tensor individually?
For example:
a = torch.tensor([[2, 5, 6], [7, 9, 4]])
result = torch.combinations(a, 2, dim=1)

results should look like
torch.Tensor([[[2, 5], 
                       [2, 6],
                       [5, 6]],

                      [[7, 9],
                       [7, 4],
                       [4, 9]]])

This seems like a natural thing to be able to do, but I haven’t been able to figure out a way to achieve this without looping. I’d appreciate any help and pointers. Thanks!