Imported from https://github.com/matthewjmackay/reversible-rnn