code: def test_whitening_transform(dim_red, metric, rndstate, get_mats):
      """Test Whitening transform"""
      n_matrices, n_channels = 20, 6
      cov = get_mats(n_matrices, n_channels, "spd")
      whit = Whitening(metric=metric).fit(cov)
      cov_w = whit.transform(cov)
      if dim_red is None:
          n_comp = n_channels
      else:
          n_comp = whit.n_components_
      assert cov_w.shape == (n_matrices, n_comp, n_comp)
      # after whitening, mean = identity
      assert_array_almost_equal(
          mean_covariance(cov_w, metric=metric),
          np.eye(n_comp),
          decimal=3,
      )
      if dim_red is not None and "max_cond" in dim_red.keys():
          assert np.linalg.cond(cov_w.mean(axis=0)) <= max_cond
  
file_path: pyRiemann/tests/test_preprocessing.py
imports: import numpy
  from numpy.testing import assert_array_almost_equal
  import pytest
  from pyriemann.spatialfilters import Whitening
  from pyriemann.utils.mean import mean_covariance
label_desc: Use image node_id 4 for calling a global function with example usage: test_whitening_transform(dim_red, metric, rndstate, get_mats) without return types