Hi Mat, I think I managed to find a way to do it in a function!
#| export
def autoreload():
from IPython.core.interactiveshell import InteractiveShell
get_ipython().run_line_magic(magic_name="load_ext", line = "autoreload")
get_ipython().run_line_magic(magic_name="autoreload", line = "2")