code: def test_psd_array_welch_nperseg_kwarg():
      """Test n_per_seg and padding in psd_array_welch()."""
      data, sfreq, _ = _make_psd_data()
      # prepare kwargs
      kwargs = dict(fmin=2, fmax=70, n_per_seg=128)
      # test n_per_seg in psd_array_welch (and padding)
      psds1, freqs1 = psd_array_welch(data, sfreq, n_fft=128, **kwargs)
      psds2, freqs2 = psd_array_welch(data, sfreq, n_fft=256, **kwargs)
      assert len(freqs1) == np.floor(len(freqs2) / 2.0)
      assert psds1.shape[-1] == np.floor(psds2.shape[-1] / 2.0)
      # test bad n_fft
      with pytest.raises(
          ValueError, match="n_fft is not allowed to be > n_tim"
      ):
          kwargs.update(n_per_seg=None)
          bad_n_fft = int(data.shape[-1] * 1.1)
          psd_array_welch(data, sfreq, n_fft=bad_n_fft, **kwargs)
      # test bad n_overlap
      with pytest.raises(
          ValueError, match="n_overlap cannot be greater"
      ):
          kwargs.update(n_per_seg=64)
          psd_array_welch(
              data, sfreq, n_fft=128, n_overlap=90, **kwargs
          )
      # test bad fmin/fmax
      with pytest.raises(ValueError, match="No frequencies found"):
          psd_array_welch(data, sfreq, fmin=10, fmax=1)
  
file_path: mne-python/mne/time_frequency/tests/test_psd.py
imports: import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal
  from scipy.signal import welch
  from mne.time_frequency import psd_array_multitaper, psd_array_welch
  from mne.time_frequency.multitaper import _psd_from_mt
  from mne.time_frequency.psd import _median_biases
  from mne.utils import catch_logging
label_desc: Use image node_id 4 for calling a global function with example usage: test_psd_array_welch_nperseg_kwarg() without return types