class_docstr_tok: []
code: def __init__(self, comms: Comm, cell_doc: Document) -> None:
      self._cellno = None
      try:
          from IPython import get_ipython
  
          ip = get_ipython()
          assert ip is not None
          hm = ip.history_manager
          assert hm is not None
          p_prompt = next(iter(hm.get_tail(1, include_latest=True)))[1]
          self._cellno = p_prompt
      except Exception as e:
          log.debug("Could not get Notebook cell number, reason: %s", e)
  
      self._comms = comms
      self._doc = cell_doc
  
      # Our internal copy of the doc is in perpetual "hold". Events from the
      # originating doc will be triggered and collected it it. Events are
      # processed/cleared when push_notebook is called for this comms handle
      self._doc.hold()
  
imports: from __future__ import annotations
  import logging
  import json
  import os
  import urllib
  from typing import TYPE_CHECKING, Any, Callable, Literal, Protocol, TypedDict, Union, cast, overload
  from uuid import uuid4
  from ..core.types import ID
  from ..util.serialization import make_id
  from ..util.warnings import warn
  from .state import curstate
label_desc: Use image node_id 1 to create a new CommsHandle object  with example: obj = CommsHandle(comms, cell_doc)