code: def test_compute_whitener(proj, pca):
      """Test properties of compute_whitener."""
      raw = read_raw_fif(raw_fname).crop(0, 3).load_data()
      raw.pick(picks=["meg", "eeg"])
      if proj:
          raw.apply_proj()
      else:
          raw.del_proj()
      with pytest.warns(RuntimeWarning, match="Too few samples"):
          cov = compute_raw_covariance(raw)
      assert cov["names"] == raw.ch_names
      W, _, C = compute_whitener(
          cov, raw.info, pca=pca, return_colorer=True, verbose="error"
      )
      n_channels = len(raw.ch_names)
      n_reduced = len(raw.ch_names)
      rank = n_channels - len(raw.info["projs"])
      n_reduced = rank if pca is True else n_channels
      assert W.shape == C.shape[::-1] == (n_reduced, n_channels)
      # round-trip mults
      round_trip = np.dot(W, C)
      if pca is True:
          assert_allclose(round_trip, np.eye(n_reduced), atol=1e-7)
      elif pca == "white":
          # Our first few rows/cols are zeroed out in the white space
          assert_allclose(
              round_trip[-rank:, -rank:], np.eye(rank), atol=1e-7
          )
      else:
          assert pca is False
          assert_allclose(round_trip, np.eye(n_channels), atol=0.05)
  
      raw.info["bads"] = [raw.ch_names[0]]
      picks = pick_types(raw.info, meg=True, eeg=True, exclude=[])
      with pytest.warns(RuntimeWarning, match="Too few samples"):
          cov2 = compute_raw_covariance(raw, picks=picks)
          cov3 = compute_raw_covariance(raw, picks=None)
      assert_allclose(cov2["data"][1:, 1:], cov3["data"])
      W2, _, C2 = compute_whitener(
          cov2,
          raw.info,
          pca=pca,
          return_colorer=True,
          picks=picks,
          verbose="error",
      )
      W3, _, C3 = compute_whitener(
          cov3,
          raw.info,
          pca=pca,
          return_colorer=True,
          picks=None,
          verbose="error",
      )
      # this tol is not great, but Windows needs it
      rtol = 1e-3 if sys.platform.startswith("win") else 1e-11
      assert_allclose(W, W2, rtol=rtol)
      assert_allclose(C, C2, rtol=rtol)
      n_channels = len(raw.ch_names) - len(raw.info["bads"])
      n_reduced = len(raw.ch_names) - len(raw.info["bads"])
      rank = n_channels - len(raw.info["projs"])
      n_reduced = rank if pca is True else n_channels
      assert W3.shape == C3.shape[::-1] == (n_reduced, n_channels)
  
imports: import itertools
  import sys
  from inspect import signature
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_equal
  from mne import Epochs, compute_covariance, compute_proj_raw, compute_rank, compute_raw_covariance, create_info, find_events, make_ad_hoc_cov, make_fixed_length_events, merge_events, pick_channels_cov, pick_info, pick_types, read_cov, read_evokeds, write_cov
  from mne._fiff.pick import _DATA_CH_TYPES_SPLIT
  from mne.channels import equalize_channels
  from mne.cov import _auto_low_rank_model, _regularized_covariance, compute_whitener, prepare_noise_cov, regularize, whiten_evoked
  from mne.datasets import testing
  from mne.fixes import _safe_svd
  from mne.io import RawArray, read_info, read_raw_ctf, read_raw_fif
  from mne.preprocessing import maxwell_filter
  from mne.rank import _compute_rank_int
  from mne.utils import _record_warnings, assert_snr, catch_logging
label_desc: Use image node_id 1 for calling a global function with example usage: test_compute_whitener(proj, pca) without return types