code: def publish(fig, event, *, verbose=None):
      """Publish an event to all subscribers of the figure's channel.
  
      The figure's event channel and all linked event channels are searched for
      subscribers to the given event. Each subscriber had provided a callback
      function when subscribing, so we call that.
  
      Parameters
      ----------
      fig : matplotlib.figure.Figure | Figure3D
          The figure that publishes the event.
      event : UIEvent
          Event to publish.
      %(verbose)s
      """
      if fig in _disabled_event_channels:
          return
  
      # Compile a list of all event channels that the event should be published
      # on.
      channels = [_get_event_channel(fig)]
      links = _event_channel_links.get(fig, None)
      if links is not None:
          for linked_fig, (
              include_events,
              exclude_events,
          ) in links.items():
              if (
                  include_events is None or event.name in include_events
              ) and (
                  exclude_events is None
                  or event.name not in exclude_events
              ):
                  channels.append(_get_event_channel(linked_fig))
  
      # Publish the event by calling the registered callback functions.
      event.source = fig
      logger.debug(f"Publishing {event} on channel {fig}")
      for channel in channels:
          if event.name not in channel:
              channel[event.name] = set()
          for callback in channel[event.name]:
              callback(event=event)
  
imports: import contextlib
  import re
  import weakref
  from dataclasses import dataclass
  from typing import Optional, Union
  from matplotlib.colors import Colormap
  from ..utils import _validate_type, fill_doc, logger, verbose, warn
label_desc: Use image node_id 2 for calling a global function with example usage: publish(fig, event) without return types