Imported from https://github.com/hannw/nlstm