code: def test_add_reorder(n_ref):
      """Test that a reference channel can be added and then data reordered."""
      # gh-8300
      raw = read_raw_fif(raw_fname).crop(0, 0.1).del_proj().pick("eeg")
      assert len(raw.ch_names) == 60
      chs = ["EEG %03d" % (60 + ii) for ii in range(1, n_ref)] + [
          "EEG 000"
      ]
      with pytest.raises(RuntimeError, match="preload"):
          with _record_warnings():  # ignore multiple warning
              add_reference_channels(raw, chs, copy=False)
      raw.load_data()
      if n_ref == 1:
          ctx = nullcontext()
      else:
          assert n_ref == 2
          ctx = pytest.warns(
              RuntimeWarning, match="locations of multiple"
          )
      with ctx:
          add_reference_channels(raw, chs, copy=False)
      data = raw.get_data()
      assert_array_equal(data[-1], 0.0)
      assert raw.ch_names[-n_ref:] == chs
      raw.reorder_channels(raw.ch_names[-1:] + raw.ch_names[:-1])
      assert raw.ch_names == [
          "EEG %03d" % ii for ii in range(60 + n_ref)
      ]
      data_new = raw.get_data()
      data_new = np.concatenate([data_new[1:], data_new[:1]])
      assert_allclose(data, data_new)
  
imports: import itertools
  from contextlib import nullcontext
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal, assert_equal
  from mne import Epochs, Projection, add_reference_channels, create_info, find_events, make_forward_solution, make_sphere_model, pick_channels, pick_channels_forward, pick_types, read_events, read_evokeds, set_bipolar_reference, set_eeg_reference, setup_volume_source_space
  from mne._fiff.constants import FIFF
  from mne._fiff.proj import _has_eeg_average_ref_proj
  from mne._fiff.reference import _apply_reference
  from mne.datasets import testing
  from mne.epochs import BaseEpochs, make_fixed_length_epochs
  from mne.io import RawArray, read_raw_fif
  from mne.utils import _record_warnings, catch_logging
label_desc: Use image node_id 9 for calling a global function with example usage: test_add_reorder(n_ref) without return types