code: def test_make_eeg_average_ref_proj():
      """Test EEG average reference projection."""
      raw = read_raw_fif(raw_fname, preload=True)
      eeg = pick_types(raw.info, meg=False, eeg=True)
  
      # No average EEG reference
      assert not np.all(raw._data[eeg].mean(axis=0) < 1e-19)
  
      # Apply average EEG reference
      car = make_eeg_average_ref_proj(raw.info)
      reref = raw.copy()
      reref.add_proj(car)
      reref.apply_proj()
      assert_array_almost_equal(
          reref._data[eeg].mean(axis=0), 0, decimal=18
      )
  
      # Error when custom reference has already been applied
      with raw.info._unlock():
          raw.info["custom_ref_applied"] = True
      pytest.raises(RuntimeError, make_eeg_average_ref_proj, raw.info)
  
      # test that an average EEG ref is not added when doing proj
      raw.set_eeg_reference(projection=True)
      assert _has_eeg_average_ref_proj(raw.info)
      raw.del_proj(idx=-1)
      assert not _has_eeg_average_ref_proj(raw.info)
      raw.apply_proj()
      assert not _has_eeg_average_ref_proj(raw.info)
  
imports: import copy
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_equal
  from scipy import linalg
  from mne import Epochs, compute_proj_epochs, compute_proj_evoked, compute_proj_raw, compute_raw_covariance, convert_forward_solution, create_info, pick_types, read_events, read_forward_solution, read_source_estimate, sensitivity_map
  from mne._fiff.proj import _EEG_AVREF_PICK_DICT, _needs_eeg_average_ref_proj, activate_proj, make_projector, setup_proj
  from mne.cov import compute_whitener, regularize
  from mne.datasets import testing
  from mne.io import RawArray, read_raw_fif
  from mne.preprocessing import maxwell_filter
  from mne.proj import _has_eeg_average_ref_proj, make_eeg_average_ref_proj, read_proj, write_proj
  from mne.rank import _compute_rank_int
  from mne.utils import _record_warnings
label_desc: Use image node_id 7 for calling a global function with example usage: test_make_eeg_average_ref_proj() without return types