harshraj22:

Assume the number of nn.LstmCell in both is 5.


That’s probably your misunderstanding. There is not a list of cells, but only cell that is recurrently used until a stop condiation is met – for the encoder, when the last word/item in the sequences as been processed.
The output of the cell at time i is used as input of the cell at the next time step i+1.
The illustrations you’ve linked just show the “unrolled” network to better visualize the sequential nature of the processing. All the cells are indeed the same cell. See the image below: both representations show the same network – left with the recurrent connection and right unrolled to better see how the sequence is processed.
RNN-unrolled2706×711 77.6 KB