WIP: BaseRecurrent and recurrent_apply_method

The scan related code is a typical boilerplate code
of which we had so much in Groundhog. This commit
introduces a way to get rid of it: a decorator that adds iteration
code to a single-step transition function.
I think that if your forward pass involves some sort of randomness, the dictionary might become non-empty because it needs to update the state of the shared RNG.