class_docstr: The IPython Kernel class.
class_docstr_tok: ["The","IPython","Kernel","class","."]
docstr: Initialize the kernel.
docstr_tok: ["Initialize","the","kernel","."]
code: def __init__(self, **kwargs):
      """Initialize the kernel."""
      super().__init__(**kwargs)
  
      # Initialize the Debugger
      if _is_debugpy_available:
          self.debugger = Debugger(
              self.log,
              self.debugpy_stream,
              self._publish_debug_event,
              self.debug_shell_socket,
              self.session,
              self.debug_just_my_code,
          )
  
      # Initialize the InteractiveShell subclass
      self.shell = self.shell_class.instance(
          parent=self,
          profile_dir=self.profile_dir,
          user_module=self.user_module,
          user_ns=self.user_ns,
          kernel=self,
          compiler_class=XCachingCompiler,
      )
      self.shell.displayhook.session = (
          self.session
      )  # type:ignore[attr-defined]
  
      jupyter_session_name = os.environ.get("JPY_SESSION_NAME")
      if jupyter_session_name:
          self.shell.user_ns["__session__"] = jupyter_session_name
  
      self.shell.displayhook.pub_socket = (
          self.iopub_socket
      )  # type:ignore[attr-defined]
      self.shell.displayhook.topic = self._topic(
          "execute_result"
      )  # type:ignore[attr-defined]
      self.shell.display_pub.session = (
          self.session
      )  # type:ignore[attr-defined]
      self.shell.display_pub.pub_socket = (
          self.iopub_socket
      )  # type:ignore[attr-defined]
  
      self.comm_manager = comm.get_comm_manager()
  
      assert isinstance(self.comm_manager, HasTraits)
      self.shell.configurables.append(
          self.comm_manager
      )  # type:ignore[arg-type]
      comm_msg_types = ["comm_open", "comm_msg", "comm_close"]
      for msg_type in comm_msg_types:
          self.shell_handlers[msg_type] = getattr(
              self.comm_manager, msg_type
          )
  
      if _use_appnope() and self._darwin_app_nap:
          # Disable app-nap as the kernel is not a gui but can have guis
          import appnope  # type:ignore[import-untyped]
  
          appnope.nope()
  
imports: import asyncio
  import builtins
  import getpass
  import os
  import signal
  import sys
  import threading
  import typing
  from contextlib import contextmanager
  from functools import partial
  import comm
  from IPython.core import release
  from IPython.utils.tokenutil import line_at_cursor, token_at_cursor
  from traitlets import Any, Bool, HasTraits, Instance, List, Type, observe, observe_compat
  from zmq.eventloop.zmqstream import ZMQStream
  from .comm.comm import BaseComm
  from .comm.manager import CommManager
  from .compiler import XCachingCompiler
  from .debugger import Debugger, _is_debugpy_available
  from .eventloops import _use_appnope
  from .kernelbase import Kernel
  from .kernelbase import _accepts_parameters
  from .zmqshell import ZMQInteractiveShell
label_desc: Use image node_id 3 to create a new IPythonKernel object from inherited base classes: KernelBase with example: obj = IPythonKernel()