code: def match_event_names(event_names, keys, *, on_missing="raise"):
      """Search a collection of event names for matching (sub-)groups of events.
  
      This function is particularly helpful when using grouped event names
      (i.e., event names containing forward slashes ``/``). Please see the
      Examples section below for a working example.
  
      Parameters
      ----------
      event_names : array-like of str | dict
          Either a collection of event names, or the ``event_id`` dictionary
          mapping event names to event codes.
      keys : array-like of str | str
          One or multiple event names or groups to search for in ``event_names``.
      on_missing : 'raise' | 'warn' | 'ignore'
          How to handle situations when none of the ``keys`` can be found in
          ``event_names``. If ``'warn'`` or ``'ignore'``, an empty list will be
          returned.
  
      Returns
      -------
      matches : list of str
          All event names that match any of the ``keys`` provided.
  
      Notes
      -----
      .. versionadded:: 1.0
  
      Examples
      --------
      Assuming the following grouped event names in the data, you could easily
      query for all ``auditory`` and ``left`` event names::
  
          >>> event_names = [
          ...     'auditory/left',
          ...     'auditory/right',
          ...     'visual/left',
          ...     'visual/right'
          ... ]
          >>> match_event_names(
          ...     event_names=event_names,
          ...     keys=['auditory', 'left']
          ... )
          ['auditory/left', 'auditory/right', 'visual/left']
      """
      _check_on_missing(on_missing)
  
      if isinstance(event_names, dict):
          event_names = list(event_names)
  
      # ensure we have a list of `keys`
      if isinstance(keys, (Sequence, np.ndarray)) and not isinstance(
          keys, str
      ):
          keys = list(keys)
      else:
          keys = [keys]
  
      matches = []
  
      # form the hierarchical event name mapping
      for key in keys:
          if not isinstance(key, str):
              raise ValueError(
                  f"keys must be strings, got {type(key)} ({key})"
              )
  
          matches.extend(
              name
              for name in event_names
              if set(key.split("/")).issubset(name.split("/"))
          )
  
      if not matches:
          _on_missing(
              on_missing=on_missing,
              msg=f'Event name "{key}" could not be found. The following events '
              f'are present in the data: {", ".join(event_names)}',
              error_klass=KeyError,
          )
  
      matches = sorted(set(matches))  # deduplicate if necessary
      return matches
  
imports: from collections.abc import Sequence
  from pathlib import Path
  import numpy
  from ._fiff.constants import FIFF
  from ._fiff.open import fiff_open
  from ._fiff.pick import pick_channels
  from ._fiff.tag import read_tag
  from ._fiff.tree import dir_tree_find
  from ._fiff.write import end_block, start_and_end_file, start_block, write_int
  from .utils import _check_fname, _check_integer_or_list, _check_on_missing, _check_option, _get_stim_channel, _on_missing, _pl, _validate_type, check_fname, fill_doc, logger, verbose, warn
label_desc: Use image node_id 16 for calling a global function with example usage: match_event_names(event_names, keys) and returns: matches