def rnn(step_function, inputs, initial_states,
        go_backwards=False, masking=False):

    def _step(input, *states):
        output, new_states = step_function(input, states)
        return [output] + new_states

    results, _ = theano.scan(
        _step,
        sequences=inputs,
        outputs_info=[None] + initial_states,
        go_backwards=go_backwards)

    # deal with Theano API inconsistency
    if type(results) is list:
        outputs = results[0]
        states = results[1:]
    else:
        outputs = results
        states = []

    last_output = outputs[-1]

    states = [T.squeeze(state[-1]) for state in states]
    return last_output, outputs, states
Iterates over the time dimension of a tensor.
dataset/ETHPy150Open sharadmv/deepx/deepx/backend/theano_backend.py/rnn