code: def test_source_psd_epochs(method):
      """Test multi-taper source PSD computation in label from epochs."""
      raw = read_raw_fif(fname_data)
      inverse_operator = read_inverse_operator(fname_inv)
      label = read_label(fname_label)
      label2 = read_label(fname_label2)
  
      event_id, tmin, tmax = 1, -0.2, 0.5
      lambda2 = 1.0 / 9.0
      bandwidth = 8.0
      fmin, fmax = 0, 100
  
      picks = pick_types(
          raw.info,
          meg=True,
          eeg=False,
          stim=True,
          ecg=True,
          eog=True,
          include=["STI 014"],
          exclude="bads",
      )
      reject = dict(grad=4000e-13, mag=4e-12, eog=150e-6)
  
      events = find_events(raw, stim_channel="STI 014")
      epochs = Epochs(
          raw,
          events,
          event_id,
          tmin,
          tmax,
          picks=picks,
          baseline=(None, 0),
          reject=reject,
      )
  
      # only look at one epoch
      epochs.drop_bad()
      one_epochs = epochs[:1]
  
      inv = prepare_inverse_operator(
          inverse_operator, nave=1, lambda2=1.0 / 9.0, method="dSPM"
      )
  
      # return list
      stc_psd = compute_source_psd_epochs(
          one_epochs,
          inv,
          lambda2=lambda2,
          method=method,
          pick_ori="normal",
          label=label,
          bandwidth=bandwidth,
          fmin=fmin,
          fmax=fmax,
          prepared=True,
      )[0]
  
      # return generator
      stcs = compute_source_psd_epochs(
          one_epochs,
          inv,
          lambda2=lambda2,
          method=method,
          pick_ori="normal",
          label=label,
          bandwidth=bandwidth,
          fmin=fmin,
          fmax=fmax,
          return_generator=True,
          prepared=True,
      )
  
      for stc in stcs:
          stc_psd_gen = stc
  
      assert_allclose(stc_psd.data, stc_psd_gen.data, atol=1e-7)
  
      # compare with direct computation
      stc = apply_inverse_epochs(
          one_epochs,
          inv,
          lambda2=lambda2,
          method=method,
          pick_ori="normal",
          label=label,
          prepared=True,
      )[0]
  
      sfreq = epochs.info["sfreq"]
      psd, freqs = psd_array_multitaper(
          stc.data,
          sfreq=sfreq,
          bandwidth=bandwidth,
          fmin=fmin,
          fmax=fmax,
      )
  
      assert_allclose(psd, stc_psd.data, atol=1e-7)
      assert_allclose(freqs, stc_psd.times)
  
      # Check corner cases caused by tiny bandwidth
      with pytest.raises(ValueError, match="use a value of at least"):
          compute_source_psd_epochs(
              one_epochs,
              inv,
              lambda2=lambda2,
              method=method,
              pick_ori="normal",
              label=label,
              bandwidth=0.01,
              low_bias=True,
              fmin=fmin,
              fmax=fmax,
              return_generator=False,
              prepared=True,
          )
  
      # check error handling for label
      with pytest.raises(TypeError, match="Label or BiHemi"):
          compute_source_psd_epochs(
              one_epochs, inv, label=[label, label2]
          )
  
file_path: mne-python/mne/minimum_norm/tests/test_time_frequency.py
imports: import numpy
  import pytest
  from numpy.testing import assert_allclose
  from mne import Epochs, find_events, pick_types
  from mne._fiff.constants import FIFF
  from mne.datasets import testing
  from mne.io import read_raw_fif
  from mne.label import BiHemiLabel, read_label
  from mne.minimum_norm import INVERSE_METHODS, apply_inverse_epochs, prepare_inverse_operator, read_inverse_operator
  from mne.minimum_norm.time_frequency import compute_source_psd, compute_source_psd_epochs, source_band_induced_power, source_induced_power
  from mne.time_frequency.multitaper import psd_array_multitaper
label_desc: Use image node_id 4 for calling a global function with example usage: test_source_psd_epochs(method) without return types