code: def _notify_stream_qt(kernel):
      import operator
      from functools import lru_cache
  
      from IPython.external.qt_for_kernel import QtCore
  
      try:
          from IPython.external.qt_for_kernel import enum_helper
      except ImportError:
  
          @lru_cache(None)
          def enum_helper(name):
              return operator.attrgetter(name.rpartition(".")[0])(
                  sys.modules[QtCore.__package__]
              )
  
      def process_stream_events():
          """fall back to main loop when there's a socket event"""
          # call flush to ensure that the stream doesn't lose events
          # due to our consuming of the edge-triggered FD
          # flush returns the number of events consumed.
          # if there were any, wake it up
          if kernel.shell_stream.flush(limit=1):
              kernel._qt_notifier.setEnabled(False)
              kernel.app.qt_event_loop.quit()
  
      if not hasattr(kernel, "_qt_notifier"):
          fd = kernel.shell_stream.getsockopt(zmq.FD)
          kernel._qt_notifier = QtCore.QSocketNotifier(
              fd,
              enum_helper("QtCore.QSocketNotifier.Type").Read,
              kernel.app.qt_event_loop,
          )
          kernel._qt_notifier.activated.connect(process_stream_events)
      else:
          kernel._qt_notifier.setEnabled(True)
  
      # there may already be unprocessed events waiting.
      # these events will not wake zmq's edge-triggered FD
      # since edge-triggered notification only occurs on new i/o activity.
      # process all the waiting events immediately
      # so we start in a clean state ensuring that any new i/o events will notify.
      # schedule first call on the eventloop as soon as it's running,
      # so we don't block here processing events
      if not hasattr(kernel, "_qt_timer"):
          kernel._qt_timer = QtCore.QTimer(kernel.app)
          kernel._qt_timer.setSingleShot(True)
          kernel._qt_timer.timeout.connect(process_stream_events)
      kernel._qt_timer.start(0)
  
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 3 for calling a global function with example usage: _notify_stream_qt(kernel) and returns: operator