lru_cache might not work as expected with ipykernel?
# lib.py
def some_function():
import spm12
eng = spm12.get_matlab()
...
# ipython
In[*]: import lib
In[*]: lib.some_function()
In[*]: import spm12
In[*]: spm12.get_matlab() # error: cannot find matlab session