code: def _test_csd_matrix(csd):
      """Perform a suite of tests on a CSD matrix."""
      # Check shape of the CSD matrix
      n_chan = len(csd.ch_names)
      assert n_chan == 3
      assert csd.ch_names == ["CH1", "CH2", "CH3"]
      n_freqs = len(csd.frequencies)
      assert n_freqs == 3
      assert csd._data.shape == (
          6,
          3,
      )  # Only upper triangle of CSD matrix
  
      # Extract CSD ndarrays. Diagonals are PSDs.
      csd_10 = csd.get_data(index=0)
      csd_22 = csd.get_data(index=2)
      power_10 = np.diag(csd_10)
      power_22 = np.diag(csd_22)
  
      # Check if the CSD matrices are hermitian
      assert np.all(np.tril(csd_10).T.conj() == np.triu(csd_10))
      assert np.all(np.tril(csd_22).T.conj() == np.triu(csd_22))
  
      # Off-diagonals show phase difference
      assert np.abs(csd_10[0, 1].imag) > 0.4
      assert np.abs(csd_10[0, 2].imag) > 0.4
      assert np.abs(csd_10[1, 2].imag) > 0.4
  
      # No phase differences at 22 Hz
      assert np.all(np.abs(csd_22[0, 2].imag) < 1e-3)
  
      # Test CSD between the two channels that have a 20Hz signal and the one
      # that has only a 10 Hz signal
      assert np.abs(csd_22[0, 2]) > np.abs(csd_22[0, 1])
      assert np.abs(csd_22[0, 2]) > np.abs(csd_22[1, 2])
  
      # Check that electrodes/frequency combinations with signal have more
      # power than frequencies without signal.
      power_15 = np.diag(csd.get_data(index=1))
      assert np.all(power_10 > power_15)
      assert np.all(power_22[[0, -1]] > power_15[[0, -1]])
  
imports: import pickle
  from itertools import product
  from os import path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal
  from pytest import raises
  import mne
  from mne.channels import equalize_channels
  from mne.proj import Projection
  from mne.time_frequency import CrossSpectralDensity, csd_array_fourier, csd_array_morlet, csd_array_multitaper, csd_fourier, csd_morlet, csd_multitaper, csd_tfr, pick_channels_csd, read_csd, tfr_morlet
  from mne.time_frequency.csd import _sym_mat_to_vector, _vector_to_sym_mat
  from mne.utils import sum_squared
label_desc: Use image node_id 13 for calling a global function with example usage: _test_csd_matrix(csd) without return types