Hi,
This will do the trick and as it is the builtin function, it is the most efficient way!:
x = torch.tensor([5, 27])
y = torch.tensor([1, 20, 3])

torch.cartesian_prod(x, y)

For more info, visit official docs 2.
Bests