code: public static <T> JavaRDD<T>[] balancedRandomSplit(int totalObjectCount, int numObjectsPerSplit, JavaRDD<T> data) {
          return balancedRandomSplit(totalObjectCount, numObjectsPerSplit, data, new Random().nextLong());
      }
docs: Random split the specified RDD into a number of RDDs, where each has {@code numObjectsPerSplit} in them.
  <p>
  This similar to how RDD.randomSplit works (i.e., split via filtering), but this should result in more
  equal splits (instead of independent binomial sampling that is used there, based on weighting)
  This balanced splitting approach is important when the number of DataSet objects we want in each split is small,
  as random sampling variance of {@link JavaRDD#randomSplit(double[])} is quite large relative to the number of examples
  in each split. Note however that this method doesn't <i>guarantee</i> that partitions will be balanced
  <p>
  Downside is we need total object count (whereas {@link JavaRDD#randomSplit(double[])} does not). However, randomSplit
  requires a full pass of the data anyway (in order to do filtering upon it) so this should not add much overhead in practice
  
  @param totalObjectCount   Total number of objects in the RDD to split
  @param numObjectsPerSplit Number of objects in each split
  @param data               Data to split
  @param <T>                Generic type for the RDD
  @return The RDD split up (without replacement) into a number of smaller RDDs