Thanks @nicofish, my question was probably unclear, sorry about that. What I want to do is to have variable batch sizes in the DataLoader. I want to assign all X,y pairs belonging to user 1 to batch 1, user 2 to batch 2, and so on. The seq_length and input_size are fixed for each X, so that is not an issue.