Imported from https://github.com/rahulbhalley/Recurrent-Nets-in-Pytorch