code: def make_qt_app_for_kernel(gui, kernel):
      """Sets the `QT_API` environment variable if it isn't already set."""
      if hasattr(kernel, "app"):
          # Kernel is already running a Qt event loop, so there's no need to
          # create another app for it.
          return
  
      set_qt_api_env_from_gui(gui)
  
      # This import is guaranteed to work now:
      from IPython.external.qt_for_kernel import QtCore
      from IPython.lib.guisupport import get_app_qt4
  
      kernel.app = get_app_qt4([" "])
      kernel.app.qt_event_loop = QtCore.QEventLoop(kernel.app)
  
imports: import os
  import platform
  import sys
  from functools import partial
  import zmq
  from packaging.version import Version
  from traitlets.config.application import Application
label_desc: Use image node_id 20 for calling a global function with example usage: make_qt_app_for_kernel(gui, kernel) without return types