code: def record_magic(dct, magic_kind, magic_name, func):
      """Utility function to store a function as a magic of a specific kind.
  
      Parameters
      ----------
      dct : dict
        A dictionary with 'line' and 'cell' subdicts.
  
      magic_kind : str
        Kind of magic to be stored.
  
      magic_name : str
        Key to store the magic as.
  
      func : function
        Callable object to store.
      """
      if magic_kind == "line_cell":
          dct["line"][magic_name] = dct["cell"][magic_name] = func
      else:
          dct[magic_kind][magic_name] = func
  
imports: from __future__ import print_function
  import os
  import re
  import sys
  import types
  from getopt import getopt, GetoptError
  from traitlets.config.configurable import Configurable
  from IPython.core import oinspect
  from IPython.core.error import UsageError
  from IPython.core.inputsplitter import ESC_MAGIC, ESC_MAGIC2
  from decorator import decorator
  from IPython.utils.ipstruct import Struct
  from IPython.utils.process import arg_split
  from IPython.utils.py3compat import string_types, iteritems
  from IPython.utils.text import dedent
  from traitlets import Bool, Dict, Instance, observe
  from logging import error
label_desc: Use image node_id 5 for calling a global function with example usage: record_magic(dct, magic_kind, magic_name, func) without return types