Hi! I am not some expert here but I will try to answer. The picture you have attached is for a keras model right?
Refer this stackoverflow link 1.
I don’t use Keras (but from reading docs), it seems that using return sequences = True will return the hidden state output for each input time step.
For this, you may use a LSTMCell maybe with a for loop to collect all the timesteps(slow I guess, somebody correct me) or you can just use  the output provided by the LSTM.  (See the docs for nn.LSTM)
Outputs: output, (h_n, c_n)
output of shape (seq_len, batch, num_directions * hidden_size): tensor containing the output features (h_t) from the last layer of the LSTM, for each t. 
If a torch.nn.utils.rnn.PackedSequence has been given as the input, 
the output will also be a packed sequence.

h_n of shape (num_layers * num_directions, batch, hidden_size): tensor containing the hidden state for t = seq_len.

c_n of shape (num_layers * num_directions, batch, hidden_size): tensor containing the cell state for t = seq_len.


So before lstm_5, it seems the keras network uses all the hidden time steps.
After that, it is only passing the latest hidden state through the network. So, you can just take the hidden state using nn.LSTM.