Pack_padded_sequence, pad_packed_sequence

I want to use the last hidden state for bilstm, for each batch, I firstly sort each example that is in the same batch. and then use pack_padded_sequence->lstm → pad_packed_sequence. then Back to the original position。 but I want to use the last hidden state. is that right in my code


?