code: public int[] sampleBatchWithoutReplacement() {
          int[] batch = new int[batchSize];
          for (int i=0; i<batch.length; i++) {
              if (cur == indices.length) {
                  cur = 0;
              }
              if (cur == 0) {
                  IntArrays.shuffle(indices);
              }
              batch[i] = indices[cur++];
          }
          return batch;
      }
docs: Samples a batch of indices in the range [0, numExamples) without replacement.