code: def test_match_event_names():
      """Test event name / event group matching."""
      event_names = [
          "auditory/left",
          "auditory/right",
          "visual/left",
          "visual/right",
      ]
  
      keys = ["auditory", "left"]
      expected_matches = [
          "auditory/left",
          "auditory/right",
          "visual/left",
      ]
      matches = match_event_names(event_names=event_names, keys=keys)
      assert matches == expected_matches
  
      # `keys` order shouldn't matter
      keys = ["left", "auditory"]
      matches = match_event_names(event_names=event_names, keys=keys)
      assert matches == expected_matches
  
      # Test `keys` is string
      keys = "left"
      expected_matches = ["auditory/left", "visual/left"]
      matches = match_event_names(event_names=event_names, keys=keys)
      assert matches == expected_matches
  
      # Test `keys` is invalid type
      for keys in (123, [123, 456]):
          with pytest.raises(ValueError, match="keys must be strings"):
              match_event_names(event_names=event_names, keys=keys)
  
      # Test no matches
      keys = "laboratory"
      with pytest.raises(KeyError, match="could not be found"):
          match_event_names(event_names=event_names, keys=keys)
  
      with pytest.warns(RuntimeWarning, match="could not be found"):
          matches = match_event_names(
              event_names=event_names, keys=keys, on_missing="warn"
          )
          assert matches == []
  
      matches = match_event_names(
          event_names=event_names, keys=keys, on_missing="ignore"
      )
      assert matches == []
  
imports: import os
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_equal
  from mne import Annotations, Epochs, compute_raw_covariance, count_events, create_info, find_events, find_stim_steps, make_fixed_length_events, pick_channels, pick_events, read_events, read_evokeds, write_events
  from mne.datasets import testing
  from mne.event import AcqParserFIF, define_target_events, match_event_names, merge_events, shift_time_events
  from mne.io import RawArray, read_raw_fif
label_desc: Use image node_id 13 for calling a global function with example usage: test_match_event_names() without return types