code: def register_comm_target(kernel=None):
      
      if kernel is None:
          kernel = get_ipython().kernel
      kernel.comm_manager.register_target('jupyter.widget', Widget.handle_comm_opened)
docs: Register the jupyter.widget comm target