code: def test_whitening_fit(dim_red, metric, rndstate, get_mats):
      """Test Whitening fit"""
      n_matrices, n_channels = 20, 6
      cov = get_mats(n_matrices, n_channels, "spd")
  
      w = rndstate.rand(n_matrices)
      whit = Whitening(dim_red=dim_red, metric=metric).fit(
          cov, sample_weight=w
      )
      if dim_red is None:
          n_comp = n_channels
      else:
          n_comp = whit.n_components_
  
      if dim_red and list(dim_red.keys())[0] in [
          "expl_var",
          "max_cond",
      ]:
          assert whit.n_components_ <= n_channels
      else:
          assert whit.n_components_ == n_comp
      assert whit.filters_.shape == (n_channels, n_comp)
      assert whit.inv_filters_.shape == (n_comp, n_channels)
  
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 3 for calling a global function with example usage: test_whitening_fit(dim_red, metric, rndstate, get_mats) without return types