code: def __init__(self, xp: exp.Experiment, comm_name: str) -> None:
      self._exp = xp
      self._num_recv = 0
      self._selected_ids: t.List[str] = []
      self._last_data_per_type: t.Dict[str, t.Any] = {}
  
      def target_func(
          comm: Comm, open_msg: t.Dict[str, t.Any]
      ) -> None:  # pylint: disable=unused-argument
          # comm is the kernel Comm instance
          # msg is the comm_open message
  
          # Register handler for later messages
          @comm.on_msg  # type: ignore
          def _recv(msg: t.Dict[str, t.Any]) -> None:
              self._num_recv += 1
              msg_data = msg["content"]["data"]
              print(msg_data)
              self._last_data_per_type[msg_data["type"]] = msg_data[
                  "data"
              ]
  
      try:
          ip: Any = get_ipython()  # type: ignore  # pylint: disable=undefined-variable
          ip.kernel.comm_manager.register_target(comm_name, target_func)
      except NameError:  # NameError: name 'get_ipython' is not defined
          # We are not in an ipython environment - for example in testing
          pass
  
imports: import uuid
  import html
  import typing
  import json
  from pathlib import Path
  import IPython.display
  from ipykernel.comm import Comm
  from .None import experiment
  from .render import escapejs, make_experiment_standalone_page
label_desc: Use image node_id 1 to create a new IPythonExperimentDisplayed object from inherited base classes: exp with example: obj = IPythonExperimentDisplayed(xp, comm_name)