Enhancement

The new function takes care to reset all the tensor we don't need to save.

It will be more robust to the next `nn` update.