code: def unsubscribe(fig, event_names, callback=None, *, verbose=None):
      """Unsubscribe from an event on a figure's event channel.
  
      Parameters
      ----------
      fig : matplotlib.figure.Figure | Figure3D
          The figure of which event channel to unsubscribe from.
      event_names : str | list of str
          Select which events to stop subscribing to. Can be a single string
          event name, a list of event names or ``"all"`` which will unsubscribe
          from all events.
      callback : callable | None
          The callback function that should be unsubscribed, leaving all other
          callback functions that may be subscribed untouched. By default
          (``None``) all callback functions are unsubscribed from the event.
      %(verbose)s
      """
      channel = _get_event_channel(fig)
  
      # Determine which events to unsubscribe for.
      if event_names == "all":
          if callback is None:
              event_names = list(channel.keys())
          else:
              event_names = list(
                  k for k, v in channel.items() if callback in v
              )
      elif isinstance(event_names, str):
          event_names = [event_names]
  
      for event_name in event_names:
          if event_name not in channel:
              warn(
                  f'Cannot unsubscribe from event "{event_name}" as we have never '
                  "subscribed to it."
              )
              continue
  
          if callback is None:
              del channel[event_name]
          else:
              # Unsubscribe specific callback function.
              subscribers = channel[event_name]
              if callback in subscribers:
                  subscribers.remove(callback)
              else:
                  warn(
                      f'Cannot unsubscribe {callback} from event "{event_name}" '
                      "as it was never subscribed to it."
                  )
              if len(subscribers) == 0:
                  del channel[event_name]
  
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 4 for calling a global function with example usage: unsubscribe(fig, event_names, callback) without return types