Hm, I also do not think that the loop for the encoder here is necessary (and probably would wouldn’t work correctly in case the GRU layer would be bidirectional). I would almost argue that this loop wasn’t in the first version of the tutorial since I used it as baseline for my own code, and I give the whole sequence at once to the GRU layer.
Doing it using a loop obviously allows you to modify the hidden state after each time step (if there are meaningful ways to do it), but here it’s not needed.