code: def test_spectrum_array_errors(epochs_spectrum):
      """Test EpochsSpectrumArray constructor errors."""
      data, freqs = epochs_spectrum.get_data(return_freqs=True)
      info = epochs_spectrum.info
      with pytest.raises(ValueError, match="Data must be a 3D array"):
          EpochsSpectrumArray(np.empty((2, 3, 4, 5)), info, freqs)
      with pytest.raises(
          ValueError, match=r"number of channels.*good data channels"
      ):
          EpochsSpectrumArray(data[:, :-1], info, freqs)
      with pytest.raises(
          ValueError, match=r"last dimension.*same number of elements"
      ):
          EpochsSpectrumArray(data[..., :-1], info, freqs)
      # test mismatching events shape
      n_epo = data.shape[0] + 1  # +1 so they purposely don't match
      events = np.vstack(
          (
              np.arange(n_epo),
              np.zeros(n_epo, dtype=int),
              np.ones(n_epo, dtype=int),
          )
      ).T
      with pytest.raises(
          ValueError, match=r"first dimension.*dimension of `events`"
      ):
          EpochsSpectrumArray(data, info, freqs, events)
  
imports: from functools import partial
  import numpy
  import pytest
  from matplotlib.colors import same_color
  from numpy.testing import assert_array_equal
  from mne import Annotations
  from mne.time_frequency import read_spectrum
  from mne.time_frequency.spectrum import EpochsSpectrumArray, SpectrumArray
label_desc: Use image node_id 16 for calling a global function with example usage: test_spectrum_array_errors(epochs_spectrum) without return types