Learning Phrase Representations using RNN Encoder–Decoder for Statistical Machine Translation 7 proposed modified version of RNN which is used in Neural Machine Translation by Jointly Learning to Align and Translate 6. In modification of RNN they are changing hidden layer computation of RNN. Many people have implemented this in PyTorch but I seen all of them have just used base RNN models in both Encoder and Decoder which actually needs internal modification. So is there any way we can change hidden layer computation of RNN or LSTM? or If not, how can I build it from scratch in PyTorch?