code: def test_csd_morlet():
      """Test computing cross-spectral density using Morlet wavelets."""
      epochs = _generate_coherence_data()
      sfreq = epochs.info["sfreq"]
  
      # Compute CSDs by a variety of methods
      freqs = [10, 15, 22]
      n_cycles = [20, 30, 44]
      times = [(None, None), (1, 9)]
      as_arrays = [False, True]
      parameters = product(times, as_arrays)
      for (tmin, tmax), as_array in parameters:
          if as_array:
              csd = csd_array_morlet(
                  epochs.get_data(copy=False),
                  sfreq,
                  freqs,
                  t0=epochs.tmin,
                  n_cycles=n_cycles,
                  tmin=tmin,
                  tmax=tmax,
                  ch_names=epochs.ch_names,
              )
          else:
              csd = csd_morlet(
                  epochs,
                  frequencies=freqs,
                  n_cycles=n_cycles,
                  tmin=tmin,
                  tmax=tmax,
              )
          if tmin is None and tmax is None:
              assert csd.tmin == 0 and csd.tmax == 9.98
          else:
              assert csd.tmin == tmin and csd.tmax == tmax
          _test_csd_matrix(csd)
  
      # CSD diagonals should contain PSD
      tfr = tfr_morlet(epochs, freqs, n_cycles, return_itc=False)
      power = np.mean(tfr.data, 2)
      csd = csd_morlet(epochs, frequencies=freqs, n_cycles=n_cycles)
      assert_allclose(csd._data[[0, 3, 5]] * sfreq, power)
  
      # Test using plain convolution instead of FFT
      csd = csd_morlet(
          epochs, frequencies=freqs, n_cycles=n_cycles, use_fft=False
      )
      assert_allclose(csd._data[[0, 3, 5]] * sfreq, power)
  
      # Test baselining warning
      epochs_nobase = epochs.copy()
      epochs_nobase.baseline = None
      with epochs_nobase.info._unlock():
          epochs_nobase.info["highpass"] = 0
      with pytest.warns(RuntimeWarning, match="baseline"):
          csd = csd_morlet(epochs_nobase, frequencies=[10], decim=20)
  
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 17 for calling a global function with example usage: test_csd_morlet() without return types