How to invoke a cell magic inside a function? Consider the following program, which I wrote in two Jupyter Notebook cells.