code: def lp_to_simple_rdd(
      lp_rdd: RDD, categorical: bool = False, nb_classes: int = None
  ):
      """Convert a LabeledPoint RDD into an RDD of feature-label pairs
  
      :param lp_rdd: LabeledPoint RDD of features and labels
      :param categorical: boolean, if labels should be one-hot encode when returned
      :param nb_classes: int, number of total classes
      :return: Spark RDD with feature-label pairs
      """
      if categorical:
          if not nb_classes:
              labels = np.asarray(
                  lp_rdd.map(lambda lp: lp.label).collect(),
                  dtype="int32",
              )
              nb_classes = np.max(labels) + 1
          rdd = lp_rdd.map(
              lambda lp: (
                  from_vector(lp.features),
                  encode_label(lp.label, nb_classes),
              )
          )
      else:
          rdd = lp_rdd.map(
              lambda lp: (from_vector(lp.features), lp.label)
          )
      return rdd
  
file_path: elephas/elephas/utils/rdd_utils.py
imports: from pyspark import RDD, SparkContext
  from pyspark.mllib.regression import LabeledPoint
  import numpy
  from ..mllib.adapter import to_vector, from_vector
label_desc: Use image node_id 5 for calling a global function with example usage: lp_to_simple_rdd(lp_rdd, categorical, nb_classes) and returns: rdd