Fix memory leak in scan related to the input and output storage of the inner function.

This fixes a memory exhaustion error on the GPU for the recurrent LSTM speech model.

It was also only lightly tested as it's really late.  Sorry if there are stupid typos or something like that.
Can you add some comments? It took me a while to be sure it is good. Something like this:

We must do as Function.__call__ and release the reference to the inputs/outputs of the internal function, as it use a different storage_map then the outer graph.

Also, I think that we should always remove them, as scan will won't reuse the inputs/outputs anyway. Check the code of each iteration before the fall to(). It seem to override all the inputs and outputs storage. Maybe it don't do it for all, but it do it for most of them. Should we do it for all of them? It think so, just because it is simpler...