You’ll have to either write code for hierarchical sampling (timeseries, then random slice) or cut some tails (with nn.utils.rnn.pack_padded_sequence perhaps). Sounds like you’re using a simple 2d data loader, it is probabably best to fix things at that level, than attempting to implement mid-sequence reset schemes.