code: @Override
      public DataSet next(int num) {
          if (!hasNext()) {
              throw new NoSuchElementException("No next element");
          }
          DataSet next;
          batch++;
          iterationsCounter.incrementAndGet();
          if (iter == null) {
              // return full DataSet
              if (num == -1) {
                  next = ds;
                  if (epochs < numEpochs)
                      trackEpochs();
              }
              // return DataSet broken into batches
              else {
                  if (batchedDS.isEmpty() && num > 0)
                      batchedDS = ds.batchBy(num);
                  next = batchedDS.get(batch);
                  if (batch + 1 == batchedDS.size()) {
                      trackEpochs();
                      if (epochs < numEpochs)
                          batch = -1;
                  }
              }
          } else {
              next = (num == -1 ? iter.next() : iter.next(num));
              if (next == null) {
                  throw new IllegalStateException("Iterator returned null DataSet");
              }
              if (!iter.hasNext()) {
                  trackEpochs();
                  // track number of epochs and won't reset if it's over
                  if (epochs < numEpochs) {
                      iter.reset();
                      lastBatch = batch;
                      batch = 0;
                  }
              }
          }
          if (preProcessor != null)
              preProcessor.preProcess(next);
          return next;
      }
docs: Like the standard next method but allows a
  customizable number of examples returned
  
  @param num the number of examples
  @return the next data applyTransformToDestination