code: def test_plot_bem():
      """Test plotting of BEM contours."""
      pytest.importorskip("nibabel")
      with pytest.raises(OSError, match="MRI file .* not found"):
          plot_bem(subject="bad-subject", subjects_dir=subjects_dir)
      with pytest.raises(
          ValueError, match="Invalid value for the 'orientation"
      ):
          plot_bem(
              subject="sample",
              subjects_dir=subjects_dir,
              orientation="bad-ori",
          )
      with pytest.raises(ValueError, match="sorted 1D array"):
          plot_bem(
              subject="sample",
              subjects_dir=subjects_dir,
              slices=[0, 500],
          )
      fig = plot_bem(
          subject="sample",
          subjects_dir=subjects_dir,
          orientation="sagittal",
          slices=[25, 50],
      )
      assert len(fig.axes) == 2
      assert len(fig.axes[0].collections) == 3  # 3 BEM surfaces ...
      fig = plot_bem(
          subject="sample",
          subjects_dir=subjects_dir,
          orientation="coronal",
          brain_surfaces="white",
      )
      assert (
          len(fig.axes[0].collections) == 5
      )  # 3 BEM surfaces + 2 hemis
      fig = plot_bem(
          subject="sample",
          subjects_dir=subjects_dir,
          orientation="coronal",
          slices=[25, 50],
          src=src_fname,
      )
      assert (
          len(fig.axes[0].collections) == 4
      )  # 3 BEM surfaces + 1 src contour
      with pytest.raises(ValueError, match="MRI coordinates, got head"):
          plot_bem(
              subject="sample", subjects_dir=subjects_dir, src=inv_fname
          )
  
imports: from pathlib import Path
  import matplotlib.pyplot
  import numpy
  import pytest
  from numpy.testing import assert_array_equal
  from mne import SourceEstimate, pick_events, read_cov, read_dipole, read_events, read_evokeds, read_source_spaces
  from mne.chpi import compute_chpi_snr
  from mne.datasets import testing
  from mne.filter import create_filter
  from mne.io import read_raw_fif
  from mne.minimum_norm import read_inverse_operator
  from mne.time_frequency import CrossSpectralDensity
  from mne.viz import plot_bem, plot_chpi_snr, plot_csd, plot_events, plot_filter, plot_snr_estimate, plot_source_spectrogram
  from mne.viz.misc import _handle_event_colors
  from mne.viz.utils import _get_color_list
label_desc: Use image node_id 5 for calling a global function with example usage: test_plot_bem() without return types