code: def requires_ipython(fn):
      """Decorator for methods that can only be run in IPython."""
  
      @functools.wraps(fn)
      def run_if_ipython(*args, **kwargs):
          """Invokes `fn` if called from IPython, otherwise just emits a warning."""
          if getattr(builtins, "__IPYTHON__", None):
              # __IPYTHON__ variable is set by IPython, see
              # https://ipython.org/ipython-doc/rel-0.10.2/html/interactive/reference.html#embedding-ipython.
              return fn(*args, **kwargs)
          else:
              logging.warning(
                  'Method "%s" is a no-op when invoked outside of IPython.',
                  fn.__name__,
              )
  
      return run_if_ipython
  
imports: import builtins
  import functools
  from absl import logging
label_desc: Use image node_id 1 for calling a global function with example usage: requires_ipython(fn) and returns: run_if_ipython, fn