Solved by LeviViana in post #2 
              
              
                This will do the job: 
import torch
D = 3
T = 4
x = torch.rand(T)

idx = torch.arange(T)
idx = (idx[None,:] - idx[:, None])%T

x.repeat(D).index_select(0, idx.view(-1)[:D * T]).view(D, T)

If T is very big, then you could have some memory issues, and a for loop would be better for constructing the i…