code: @Override
      public DataSet sample(int numSamples, org.nd4j.linalg.api.rng.Random rng, boolean withReplacement) {
          Set<Integer> added = new HashSet<>();
          List<DataSet> toMerge = new ArrayList<>();
          boolean terminate = false;
          for (int i = 0; i < numSamples && !terminate; i++) {
              int picked = rng.nextInt(numExamples());
              if (!withReplacement) {
                  while (added.contains(picked)) {
                      picked = rng.nextInt(numExamples());
                      if(added.size() == numExamples()){
                          terminate = true;
                          break;
                      }
                  }
              }
              added.add(picked);
              toMerge.add(get(picked));
          }
          return DataSet.merge(toMerge);
      }
docs: Sample a dataset
  
  @param numSamples      the number of samples to getFromOrigin
  @param rng             the rng to use
  @param withReplacement whether to allow duplicates (only tracked by example row number)
  @return the sample dataset