code: def test_covariances_cross_spectrum(rndstate):
      n_channels, n_times = 3, 1000
      x = rndstate.randn(n_channels, n_times)
      cross_spectrum(x)
      cross_spectrum(x, fs=128, fmin=2, fmax=40)
      cross_spectrum(x, fs=129, window=37)
  
      with pytest.raises(ValueError):  # window < 1
          cross_spectrum(x, window=0)
      with pytest.raises(ValueError):  # overlap <= 0
          cross_spectrum(x, overlap=0)
      with pytest.raises(ValueError):  # overlap >= 1
          cross_spectrum(x, overlap=1)
      with pytest.raises(ValueError):  # fmin > fmax
          cross_spectrum(x, fs=128, fmin=20, fmax=10)
      with pytest.raises(ValueError):  # fmax > fs/2
          cross_spectrum(x, fs=128, fmin=20, fmax=65)
      with pytest.warns(UserWarning):  # fs is None
          cross_spectrum(x, fmin=12)
      with pytest.warns(UserWarning):  # fs is None
          cross_spectrum(x, fmax=12)
  
      c, freqs = cross_spectrum(x, fs=128, window=256)
      assert c.shape[0] == c.shape[1] == n_channels
      assert c.shape[-1] == freqs.shape[0]
      # test if cross-spectra are hermitian,
      # ie with symmetric real parts and skew-symmetric imag parts
      assert is_hermitian(np.transpose(c, (2, 0, 1)))
      # test if DC bins are real (always true)
      assert is_real(c[..., 0])
      # test if Nyquist bins are real (true when window is even)
      assert is_real(c[..., -1])
      # test if auto-spectra are real
      assert is_real(c.diagonal())
  
      # test equivalence between pyriemann and scipy for (auto-)spectra
      x = rndstate.randn(5, n_times)
      fs, window, overlap = 128, 256, 0.75
      spect_pr, freqs_pr = cross_spectrum(
          x, fs=fs, window=window, overlap=overlap
      )
      spect_pr = np.diagonal(
          spect_pr.real
      ).T  # auto-spectra on diagonal
      spect_pr = spect_pr / np.linalg.norm(spect_pr)  # unit norm
      freqs_sp, spect_sp = welch(
          x,
          fs=fs,
          nperseg=window,
          noverlap=int(overlap * window),
          window=np.hanning(window),
          detrend=False,
          scaling="spectrum",
      )
      spect_sp /= np.linalg.norm(spect_sp)  # unit norm
      # compare frequencies
      assert_array_almost_equal(freqs_pr, freqs_sp, 6)
      # compare auto-spectra
      assert_array_almost_equal(spect_pr, spect_sp, 6)
  
      # test equivalence between pyriemann and scipy for cross-spectra
      x = rndstate.randn(2, n_times)
      fs, window, overlap = 64, 128, 0.5
      cross_pr, freqs_pr = cross_spectrum(
          x, fs=fs, window=window, overlap=overlap
      )
      cross_pr = cross_pr[0, 1] / np.linalg.norm(
          cross_pr[0, 1]
      )  # unit norm
      freqs_sp, cross_sp = csd(
          x[0],
          x[1],
          fs=fs,
          nperseg=window,
          noverlap=int(overlap * window),
          window=np.hanning(window),
          detrend=False,
          scaling="spectrum",
      )
      cross_sp /= np.linalg.norm(cross_sp)  # unit norm
      # compare frequencies
      assert_array_almost_equal(freqs_pr, freqs_sp, 6)
      # compare cross-spectra
      assert_array_almost_equal(cross_pr, cross_sp, 6)
  
imports: from numpy.testing import assert_array_almost_equal
  import numpy
  from scipy.linalg import block_diag
  from scipy.signal import welch, csd, coherence
  from sklearn.covariance import empirical_covariance
  import pytest
  from pyriemann.utils.covariance import covariances, covariances_EP, covariances_X, eegtocov, cross_spectrum, cospectrum, coherence, normalize, get_nondiag_weight, block_covariances, _complex_estimator
  from pyriemann.utils.test import is_real, is_hermitian, is_sym_pos_def, is_herm_pos_def
label_desc: Use image node_id 11 for calling a global function with example usage: test_covariances_cross_spectrum(rndstate) without return types