rnn_impl function

RNN Implementation