code: def test_plot_epochs_image(epochs):
      """Test plotting of epochs image."""
      figs = epochs.plot_image()
      assert (
          len(figs) == 2
      )  # one fig per ch_type (test data has mag, grad)
      assert len(plt.get_fignums()) == 2
      figs = epochs.plot_image()
      assert len(figs) == 2
      assert len(plt.get_fignums()) == 4  # should create new figures
      epochs.plot_image(picks="mag", sigma=0.1)
      epochs.plot_image(
          picks=[0, 1], combine="mean", ts_args=dict(show_sensors=False)
      )
      epochs.plot_image(
          picks=[1],
          order=[0],
          overlay_times=[0.1],
          vmin=0.01,
          title="test",
      )
      plt.close("all")
      epochs.plot_image(
          picks=[1], overlay_times=[0.1], vmin=-0.001, vmax=0.001
      )
      plt.close("all")
      epochs.plot_image(picks=[1], vmin=lambda x: x.min())
      # test providing figure
      fig, axs = plt.subplots(3, 1)
      epochs.plot_image(picks=[1], fig=fig)
      # test providing axes instance
      epochs.plot_image(
          picks=[1], axes=axs[0], evoked=False, colorbar=False
      )
      plt.close("all")
      # test order=callable
      epochs.plot_image(
          picks=[0, 1],
          order=lambda times, data: np.arange(len(data))[::-1],
      )
      # test warning
      with pytest.warns(
          RuntimeWarning, match="Only one channel in group"
      ):
          epochs.plot_image(picks=[1], combine="mean")
      # group_by should be a dict
      with pytest.raises(TypeError, match="dict or None"):
          epochs.plot_image(group_by="foo")
      # units and scalings keys must match
      with pytest.raises(
          ValueError, match="Scalings and units must have the"
      ):
          epochs.plot_image(units=dict(hi=1), scalings=dict(ho=1))
      plt.close("all")
      # test invert_y
      epochs.plot_image(ts_args=dict(invert_y=True))
      # can't combine different sensor types
      with pytest.raises(
          ValueError, match="Cannot combine sensors of differ"
      ):
          epochs.plot_image(group_by=dict(foo=[0, 1, 2]))
      # can't pass both fig and axes
      with pytest.raises(
          ValueError, match='one of "fig" or "axes" must be'
      ):
          epochs.plot_image(fig="foo", axes="bar")
      # wrong number of axes in fig
      with pytest.raises(
          ValueError, match='"fig" must contain . axes, got .'
      ):
          epochs.plot_image(fig=plt.figure())
      # only 1 group allowed when fig is passed
      with pytest.raises(
          ValueError, match='"group_by" can only have one group'
      ):
          fig, axs = plt.subplots(3, 1)
          epochs.plot_image(
              fig=fig, group_by=dict(foo=[0, 1], bar=[5, 6])
          )
          del fig, axs
      plt.close("all")
      # must pass correct number of axes (1, 2, or 3)
      with pytest.raises(
          ValueError, match="is a list, can only plot one group"
      ):
          fig, axs = plt.subplots(1, 3)
          epochs.plot_image(axes=axs)
      for length, kwargs in (
          [3, dict()],
          [2, dict(evoked=False)],
          [2, dict(colorbar=False)],
          [1, dict(evoked=False, colorbar=False)],
      ):
          fig, axs = plt.subplots(1, length + 1)
          epochs.plot_image(picks="mag", axes=axs[:length], **kwargs)
          with pytest.raises(
              ValueError, match='"axes" must be length ., got .'
          ):
              epochs.plot_image(picks="mag", axes=axs, **kwargs)
      plt.close("all")
      # mismatch between axes dict keys and group_by dict keys
      with pytest.raises(
          ValueError, match='must match the keys in "group_by"'
      ):
          epochs.plot_image(axes=dict())
      # wrong number of axes in dict
      match = 'each value in "axes" must be a list of . axes, got .'
      with pytest.raises(ValueError, match=match):
          epochs.plot_image(
              axes=dict(foo=axs[:2], bar=axs[:3]),
              group_by=dict(foo=[0, 1], bar=[5, 6]),
          )
      # bad value of "combine"
      with pytest.raises(
          ValueError, match='"combine" must be None, a callable'
      ):
          epochs.plot_image(combine="foo")
      # mismatched picks and overlay_times
      with pytest.raises(
          ValueError, match="size of overlay_times parameter"
      ):
          epochs.plot_image(picks=[1], overlay_times=[0.1, 0.2])
      # bad overlay times
      with pytest.warns(RuntimeWarning, match="fall outside"):
          epochs.plot_image(overlay_times=[999.0])
      # mismatched picks and order
      with pytest.raises(
          ValueError, match="must match the length of the data"
      ):
          epochs.plot_image(picks=[1], order=[0, 1])
      # with a ref MEG channel (that we "convert" from a grad channel)
      with pytest.warns(RuntimeWarning, match=".* from T/m to T.$"):
          epochs.set_channel_types({epochs.ch_names[0]: "ref_meg"})
      epochs.plot_image()
      plt.close("all")
  
imports: import platform
  import matplotlib.pyplot
  import numpy
  import pytest
  from mne import Epochs, EpochsArray, create_info
  from mne.datasets import testing
  from mne.event import make_fixed_length_events
  from mne.viz import plot_drop_log
label_desc: Use image node_id 12 for calling a global function with example usage: test_plot_epochs_image(epochs) without return types