Fix function caching for IPython

When `joblib.Memory` is used with functions defined in an interactive shell, e.g., an IPython notebook, the caching did not work, due to the following reasons:

- The code for getting the function source code did not work correctly.
- The cache directory for storing the function inputs and outputs constantly changed, which caused the function to be re-executed instead of using the cached result.  

This PR fixes both problems. For IPython the name used for the cache directory always ended with something like `<ipython-input-24-58eb75b955d1>`, which changes with every IPython kernel instance. I fixed this by replacing the pattern with `__ipython-input__`. This is a somewhat hackish solution, as functions with the same name and in the same work directory will have the same cache directory. However, I don't think there is a better solution as the function may not be defined in a file at all (it could be defined in an IPython notebook, but the IPython kernel is not aware of this).

I'm not sure how this could be tested, so I haven't added any unit tests so far.