<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_java_rdd(jsc, features, labels, batch_size):
 """Convert numpy features and labels into a JavaRDD of DL4J DataSet type. :param jsc: JavaSparkContext from pyjnius :param features: numpy array with features :param labels: numpy array with labels: :return: JavaRDD<DataSet> """

    data_sets = java_classes.ArrayList()
    num_batches = int(len(features) / batch_size)
    for i in range(num_batches):
        xi = ndarray(features[:batch_size].copy())
        yi = ndarray(labels[:batch_size].copy())
        data_set = java_classes.DataSet(xi.array, yi.array)
        data_sets.add(data_set)
        features = features[batch_size:]
        labels = labels[batch_size:]

    return jsc.parallelize(data_sets)