code: def load_notebook(fullname: str):
      
      shell = InteractiveShell.instance()
      path = fullname
  
      # load the notebook object
      with open(path, 'r', encoding='utf-8') as f:
          notebook = read(f, 4)
  
      # create the module and add it to sys.modules
      mod = types.ModuleType(fullname)
      mod.__file__ = path
      # mod.__loader__ = self
      mod.__dict__['get_ipython'] = get_ipython
      sys.modules[fullname] = mod
  
      # extra work to ensure that magics that would affect the user_ns
      # actually affect the notebook module's ns
      save_user_ns = shell.user_ns
      shell.user_ns = mod.__dict__
  
      try:
          for cell in notebook.cells:
              if cell.cell_type == 'code':
                  try:
                      # only run valid python code
                      ast.parse(cell.source)
                  except SyntaxError:
                      continue
                  try:
                      # pylint: disable=exec-used
                      exec(cell.source, mod.__dict__)
                  except NameError:
                      print(cell.source)
                      raise
      finally:
          shell.user_ns = save_user_ns
      return mod
docs: Import a notebook as a module.