code: def test_simulate_round_trip(raw_data):
      """Test simulate_raw round trip calculations."""
      # Check a diagonal round-trip
      raw, src, stc, trans, sphere = raw_data
      raw.pick(["meg", "stim"])
      bem = read_bem_solution(bem_1_fname)
      old_bem = bem.copy()
      old_src = src.copy()
      old_trans = trans.copy()
      fwd = make_forward_solution(raw.info, trans, src, bem)
      # no omissions
      assert (
          sum(len(s["vertno"]) for s in src)
          == sum(len(s["vertno"]) for s in fwd["src"])
          == 36
      )
      # make sure things were not modified
      assert (
          old_bem["surfs"][0]["coord_frame"]
          == bem["surfs"][0]["coord_frame"]
      )
      assert trans == old_trans
      _compare_source_spaces(src, old_src)
      data = np.eye(fwd["nsource"])
      raw.crop(0, len(data) / raw.info["sfreq"], include_tmax=False)
      stc = SourceEstimate(
          data,
          [s["vertno"] for s in fwd["src"]],
          0,
          1.0 / raw.info["sfreq"],
      )
      for use_fwd in (None, fwd):
          if use_fwd is None:
              use_trans, use_src, use_bem = trans, src, bem
          else:
              use_trans = use_src = use_bem = None
          this_raw = simulate_raw(
              raw.info,
              stc,
              use_trans,
              use_src,
              use_bem,
              forward=use_fwd,
          )
          this_raw.pick(["meg", "eeg"])
          assert (
              old_bem["surfs"][0]["coord_frame"]
              == bem["surfs"][0]["coord_frame"]
          )
          assert trans == old_trans
          _compare_source_spaces(src, old_src)
          this_fwd = convert_forward_solution(fwd, force_fixed=True)
          assert_allclose(
              this_raw[:][0],
              this_fwd["sol"]["data"],
              atol=1e-12,
              rtol=1e-6,
          )
      with pytest.raises(
          ValueError, match="If forward is not None then"
      ):
          simulate_raw(raw.info, stc, trans, src, bem, forward=fwd)
      # Not iterable
      with pytest.raises(
          TypeError, match="SourceEstimate, tuple, or iterable"
      ):
          simulate_raw(raw.info, 0.0, trans, src, bem, None)
      # STC with a source that `src` does not have
      assert 0 not in src[0]["vertno"]
      vertices = [[0, fwd["src"][0]["vertno"][0]], []]
      stc_bad = SourceEstimate(
          data[:2], vertices, 0, 1.0 / raw.info["sfreq"]
      )
      with pytest.warns(
          RuntimeWarning, match="1 of 2 SourceEstimate vertices"
      ):
          simulate_raw(raw.info, stc_bad, trans, src, bem)
      assert 0 not in fwd["src"][0]["vertno"]
      with pytest.warns(
          RuntimeWarning, match="1 of 2 SourceEstimate vertices"
      ):
          simulate_raw(raw.info, stc_bad, None, None, None, forward=fwd)
      # dev_head_t mismatch
      fwd["info"]["dev_head_t"]["trans"][0, 0] = 1.0
      with pytest.raises(
          ValueError, match="dev_head_t.*does not match"
      ):
          simulate_raw(raw.info, stc, None, None, None, forward=fwd)
  
imports: from copy import deepcopy
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal
  from mne import Epochs, SourceEstimate, VolSourceEstimate, convert_forward_solution, create_info, find_events, fit_dipole, make_ad_hoc_cov, make_bem_solution, make_forward_solution, make_sphere_model, pick_types, read_bem_solution, read_cov, read_source_spaces, read_trans, setup_source_space, setup_volume_source_space, transform_surface_to
  from mne._fiff.constants import FIFF
  from mne.bem import _surfaces_to_bem
  from mne.chpi import compute_chpi_amplitudes, compute_chpi_locs, compute_head_pos, get_chpi_info, read_head_pos
  from mne.datasets import testing
  from mne.io import RawArray, read_raw_fif
  from mne.label import Label
  from mne.simulation import add_chpi, add_ecg, add_eog, add_noise, simulate_raw, simulate_sparse_stc
  from mne.simulation.source import SourceSimulator
  from mne.source_space._source_space import _compare_source_spaces
  from mne.surface import _get_ico_surface
  from mne.tests.test_chpi import _assert_quats
  from mne.utils import catch_logging
label_desc: Use image node_id 9 for calling a global function with example usage: test_simulate_round_trip(raw_data) without return types