def _get_n_epochs(epochs, n):
    epochs_out = []
    for e in epochs:
        if not isinstance(e, (list, tuple)):
            e = (e,)
        epochs_out.append(e)
        if len(epochs_out) >= n:
            yield epochs_out
            epochs_out = []
    yield epochs_out
Generator that returns lists with at most n epochs
dataset/ETHPy150Open mne-tools/mne-python/mne/connectivity/spectral.py/_get_n_epochs