code: def _notify_stream_qt(kernel, stream):
      from IPython.external.qt_for_kernel import QtCore
  
      if _use_appnope() and kernel._darwin_app_nap:
          from appnope import nope_scope as context
      else:
          from contextlib import contextmanager
  
          @contextmanager
          def context():
              yield
  
      def process_stream_events():
          while stream.getsockopt(zmq.EVENTS) & zmq.POLLIN:
              with context():
                  kernel.do_one_iteration()
  
      fd = stream.getsockopt(zmq.FD)
      notifier = QtCore.QSocketNotifier(
          fd, QtCore.QSocketNotifier.Read, kernel.app
      )
      notifier.activated.connect(process_stream_events)
      # 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
      timer = QtCore.QTimer(kernel.app)
      timer.setSingleShot(True)
      timer.timeout.connect(process_stream_events)
      timer.start(0)
  
imports: import os
  import sys
  import platform
  import zmq
  from distutils.version import LooseVersion
  from traitlets.config.application import Application
  from IPython.utils import io
label_desc: Use image node_id 2 for calling a global function with example usage: _notify_stream_qt(kernel, stream) without return types