code: def test_csd_get_frequency_index():
      """Test the _get_frequency_index method of CrossSpectralDensity."""
      csd = _make_csd()
  
      assert csd._get_frequency_index(1) == 0
      assert csd._get_frequency_index(2) == 1
      assert csd._get_frequency_index(4) == 3
  
      assert csd._get_frequency_index(0.9) == 0
      assert csd._get_frequency_index(2.1) == 1
      assert csd._get_frequency_index(4.1) == 3
  
      # Frequency can be off by a maximum of 1
      raises(
          IndexError,
          csd._get_frequency_index,
          csd.frequencies[-1] + 1.0001,
      )
  
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 5 for calling a global function with example usage: test_csd_get_frequency_index() without return types