code: def _method_magic_marker(magic_kind):
      """Decorator factory for methods in Magics subclasses."""
  
      validate_type(magic_kind)
  
      # This is a closure to capture the magic_kind.  We could also use a class,
      # but it's overkill for just that one bit of state.
      def magic_deco(arg):
          if callable(arg):
              # "Naked" decorator call (just @foo, no args)
              func = arg
              name = func.__name__
              retval = arg
              record_magic(magics, magic_kind, name, name)
          elif isinstance(arg, str):
              # Decorator called with arguments (@foo('bar'))
              name = arg
  
              def mark(func, *a, **kw):
                  record_magic(magics, magic_kind, name, func.__name__)
                  return func
  
              retval = mark
          else:
              raise TypeError(
                  "Decorator can only be called with "
                  "string or function"
              )
          return retval
  
      # Ensure the resulting decorator has a usable docstring
      magic_deco.__doc__ = _docstring_template.format(
          "method", magic_kind
      )
      return magic_deco
  
imports: import os
  import re
  import sys
  from getopt import getopt, GetoptError
  from traitlets.config.configurable import Configurable
  from .None import oinspect
  from .error import UsageError
  from .inputtransformer2 import ESC_MAGIC, ESC_MAGIC2
  from ..utils.ipstruct import Struct
  from ..utils.process import arg_split
  from ..utils.text import dedent
  from traitlets import Bool, Dict, Instance, observe
  from logging import error
label_desc: Use image node_id 7 for calling a global function with example usage: _method_magic_marker(magic_kind) and returns: magic_deco, retval, func