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)

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 .