class_docstr: A display publisher that publishes data using a ZeroMQ PUB socket.
docstr: Publish a display-data message
  
  Parameters
  ----------
  data : dict
      A mime-bundle dict, keyed by mime-type.
  metadata : dict, optional
      Metadata associated with the data.
  transient : dict, optional, keyword-only
      Transient data that may only be relevant during a live display,
      such as display_id.
      Transient data should not be persisted to documents.
  update : bool, optional, keyword-only
      If True, send an update_display_data message instead of display_data.
docstr_tok: ["Publish","a","display-data","message","Parameters","--","--","--","--","--","data",":","dict","A","mime-bundle","dict",",","keyed","by","mime-type",".","metadata",":","dict",",","optional","Metadata","associated","with","the","data",".","transient",":","dict",",","optional",",","keyword-only","Transient","data","that","may","only","be","relevant","during","a","live","display",",","such","as","display_id",".","Transient","data","should","not","be","persisted","to","documents",".","update",":","bool",",","optional",",","keyword-only","If","True",",","send","an","update_display_data","message","instead","of","display_data","."]
code: def publish(
      self,
      data,
      metadata=None,
      transient=None,
      update=False,
  ):
      """Publish a display-data message
  
      Parameters
      ----------
      data : dict
          A mime-bundle dict, keyed by mime-type.
      metadata : dict, optional
          Metadata associated with the data.
      transient : dict, optional, keyword-only
          Transient data that may only be relevant during a live display,
          such as display_id.
          Transient data should not be persisted to documents.
      update : bool, optional, keyword-only
          If True, send an update_display_data message instead of display_data.
      """
      self._flush_streams()
      if metadata is None:
          metadata = {}
      if transient is None:
          transient = {}
      self._validate_data(data, metadata)
      content = {}
      content["data"] = encode_images(data)
      content["metadata"] = metadata
      content["transient"] = transient
  
      msg_type = "update_display_data" if update else "display_data"
  
      # Use 2-stage process to send a message,
      # in order to put it through the transform
      # hooks before potentially sending.
      assert self.session is not None
      msg = self.session.msg(
          msg_type, json_clean(content), parent=self.parent_header
      )
  
      # Each transform either returns a new
      # message or None. If None is returned,
      # the message has been 'used' and we return.
      for hook in self._hooks:
          msg = hook(msg)
          if msg is None:
              return  # type:ignore[unreachable]
  
      self.session.send(
          self.pub_socket,
          msg,
          ident=self.topic,
      )
  
imports: import os
  import sys
  import warnings
  from pathlib import Path
  from threading import local
  from IPython.core import page, payloadpage
  from IPython.core.autocall import ZMQExitAutocall
  from IPython.core.displaypub import DisplayPublisher
  from IPython.core.error import UsageError
  from IPython.core.interactiveshell import InteractiveShell, InteractiveShellABC
  from IPython.core.magic import Magics, line_magic, magics_class
  from IPython.core.magics import CodeMagics, MacroToEdit
  from IPython.core.usage import default_banner
  from IPython.display import Javascript, display
  from IPython.utils import openpy
  from IPython.utils.process import arg_split, system
  from jupyter_client.session import Session, extract_header
  from jupyter_core.paths import jupyter_runtime_dir
  from traitlets import Any, CBool, CBytes, Dict, Instance, Type, default, observe
  from ipykernel import connect_qtconsole, get_connection_file, get_connection_info
  from ipykernel.displayhook import ZMQShellDisplayHook
  from ipykernel.jsonutil import encode_images, json_clean
label_desc: Use image node_id 5 for calling the ZMQDisplayPublisher obj's underlying member method code with example usage: obj.publish(data, metadata, transient, update) without return types