Repeating a tensor in intercalated form

I have this tensor:

tensor([[425.0000, 625.0000],
        [550.0000, 566.6667],
        [700.0000, 600.0000]])

and I want to obtain something like this:

tensor([[425.0000, 425.0000, 625.0000, 625.0000],
        [550.0000, 550.0000, 566.6667, 566.6667],
        [700.0000, 700.0000, 600.0000, 600.0000]

Is there anyway to do this efficiently?

Maybe not the most elegant way, but this should work:

x.unsqueeze(1).permute(0, 2, 1).repeat(1, 1, 2).view(3, 4)

Thanks!! I would like to ask what is the difference between reshape, view and why sometimes view needs to be followed by the contiguous() method.

.reshape returns a view of the tensor it possible and a copy if necessary (docs).
Some operations need contiguous tensors to use e.g. the strides of the tensor internally.
If your tensor is non-contiguous, you’ll get an error, to avoid wrong computations and other side effects.