Never mind this. There are bugs in the code above, and I think I have answered my question. We shouldn’t be using the packed sequence api here, but instead deal with padding issues manually. For example, pad to max length of mini batch and then do bi lstm computation on padded sequence. Might lead to some bogus computations which probably cannot be avoided.