code: def _is_running_in_notebook():
      try:
          from IPython import get_ipython
  
          shell = get_ipython().__class__.__name__
          if shell == "ZMQInteractiveShell":
              return True  # Jupyter notebook or qtconsole
          elif shell == "TerminalInteractiveShell":
              return False  # Terminal running IPython
          else:
              return False  # Other type (?)
      except NameError:
          return False
  
imports: import os
  import re
  import sys
  import xml.etree.ElementTree
label_desc: Use image node_id 13 for calling a global function with example usage: _is_running_in_notebook() and returns: True, False, False, False