You should be able to slice the model output and targets in the temporal dimension and only pass the desired time steps to the criterion. Did you try it out and if so did you see any issues?
Unrelated to this, but you would have to permute the model output so that the shape is [batch_size, nb_classes, seq_len].