Reorganize LSTM logic
Reorganize LSTM logic

Rewrote the LSTM logic to use less repeat code. Also confirmed that it
makes no difference in the output: all the output values are identical
out to the last decimal place.

jwsmithers/lwtnn,lwtnn/lwtnn,lwtnn/lwtnn,jwsmithers/lwtnn,lwtnn/lwtnn,jwsmithers/lwtnn