Thanks a lot, @ptrblck .
Well, I think what you are doing should be exactly the same as:
tensor = torch.arange(N*M*K).view(N, M, K)
dim = 1
idx = torch.randperm(tensor.shape[dim])
t_shuffled = tensor[:,idx]

Am I right? I tried your approach and this, however, the output is not the same. t_shuffle is not as y
I just need to be sure that when the data is shuffled along the num_steps dimension the data_0 and  data_1 corresponding to the num_step being shuffled as well. Such that the 3d block of the data keeps being logical.