Solved by ptrblck in post #3 
              
              
                Alternatively to the loop, you could also interleave the tensors directly as seen here: 
x = torch.rand(4,4)
y = torch.rand(4,4)
print(x)
print(y)

z = torch.cat((x,y),0)
test = None
for  k in range(x.shape[0]):
  if test is None:
    test = torch.cat((z[k:k+1],z[k + x.shape[0]:k + x.shape[0]+1]),0)…