code: def _decomp_aggregate_mask(epoch, func, average, freq_sl):
      _, _, spect = func(epoch)
      spect = spect[..., freq_sl, :]
      # Do the averaging here (per epoch) to save memory
      if average == "mean":
          spect = np.nanmean(spect, axis=-1)
      elif average == "median":
          biases = _median_biases(spect.shape[-1])
          idx = (~np.isnan(spect)).sum(-1)
          spect = np.nanmedian(spect, axis=-1) / biases[idx]
      return spect
  
file_path: mne-python/mne/time_frequency/psd.py
imports: from functools import partial
  import numpy
  from scipy.signal import spectrogram
  from ..parallel import parallel_func
  from ..utils import _check_option, _ensure_int, logger, verbose
label_desc: Use image node_id 2 for calling a global function with example usage: _decomp_aggregate_mask(epoch, func, average, freq_sl) and returns: spect