code: def enable_gui(gui, kernel=None):
      """Enable integration with a given GUI"""
      if gui not in loop_map:
          e = f"Invalid GUI request {gui!r}, valid ones are:{loop_map.keys()}"
          raise ValueError(e)
      if kernel is None:
          if Application.initialized():
              kernel = getattr(Application.instance(), "kernel", None)
          if kernel is None:
              msg = (
                  "You didn't specify a kernel,"
                  " and no IPython Application with a kernel appears to be running."
              )
              raise RuntimeError(msg)
      if gui is None:
          # User wants to turn off integration; clear any evidence if Qt was the last one.
          if hasattr(kernel, "app"):
              delattr(kernel, "app")
      else:
          if gui.startswith("qt"):
              # Prepare the kernel here so any exceptions are displayed in the client.
              make_qt_app_for_kernel(gui, kernel)
  
      loop = loop_map[gui]
      if (
          loop
          and kernel.eventloop is not None
          and kernel.eventloop is not loop  # type:ignore[unreachable]
      ):
          msg = (
              "Cannot activate multiple GUI eventloops"
          )  # type:ignore[unreachable]
          raise RuntimeError(msg)
      kernel.eventloop = loop
  
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 21 for calling a global function with example usage: enable_gui(gui, kernel) without return types