Look at how the forward() method of Encoder is implemented. it embeds a single vector, and then runs it through the GRU (rather than LSTM here) stored on that class. the pytorch GRU and LSTM classes can, by default take a sequence in the form of [batch_length, sequence_length, embedding_dim]. You can therefore embed a sequence of input_length to be a tensor with dimensions  [1, sequence_length, embedding_dim], and run that through the LSTM in one go, allowing the efficient pytorch code to iterate over it, rather than a python loop. You can even batch your sequences and embed those, and pass them through an LSTM or GRU.