import torch ten = torch.Tensor([1, 2, 3, 4, 5, 6) ten.roll(-1, 0)
The examples in the documentation of .roll() has a scenario just like yours.
.roll()