nodes: 0, module; 1, function_definition; 2, function_name:saveAsLibSVMFile; 3, parameters; 4, block; 5, identifier:data; 6, identifier:dir; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, comment:"""
          Save labeled data in LIBSVM format.
  
          :param data: an RDD of LabeledPoint to be saved
          :param dir: directory to save the data
  
          >>> from tempfile import NamedTemporaryFile
          >>> from fileinput import input
          >>> from pyspark.mllib.regression import LabeledPoint
          >>> from glob import glob
          >>> from pyspark.mllib.util import MLUtils
          >>> examples = [LabeledPoint(1.1, Vectors.sparse(3, [(0, 1.23), (2, 4.56)])),
          ...             LabeledPoint(0.0, Vectors.dense([1.01, 2.02, 3.03]))]
          >>> tempFile = NamedTemporaryFile(delete=True)
          >>> tempFile.close()
          >>> MLUtils.saveAsLibSVMFile(sc.parallelize(examples), tempFile.name)
          >>> ''.join(sorted(input(glob(tempFile.name + "/part-0000*"))))
          '0.0 1:1.01 2:2.02 3:3.03\\n1.1 1:1.23 3:4.56\\n'
          """; 11, assignment; 12, call; 13, identifier:lines; 14, call; 15, attribute; 16, argument_list; 17, attribute; 18, argument_list; 19, identifier:lines; 20, identifier:saveAsTextFile; 21, identifier:dir; 22, identifier:data; 23, identifier:map; 24, lambda; 25, lambda_parameters; 26, call; 27, identifier:p; 28, attribute; 29, argument_list; 30, identifier:MLUtils; 31, identifier:_convert_labeled_point_to_libsvm; 32, identifier:p
code: def saveAsLibSVMFile(data, dir):
          """
          Save labeled data in LIBSVM format.
  
          :param data: an RDD of LabeledPoint to be saved
          :param dir: directory to save the data
  
          >>> from tempfile import NamedTemporaryFile
          >>> from fileinput import input
          >>> from pyspark.mllib.regression import LabeledPoint
          >>> from glob import glob
          >>> from pyspark.mllib.util import MLUtils
          >>> examples = [LabeledPoint(1.1, Vectors.sparse(3, [(0, 1.23), (2, 4.56)])),
          ...             LabeledPoint(0.0, Vectors.dense([1.01, 2.02, 3.03]))]
          >>> tempFile = NamedTemporaryFile(delete=True)
          >>> tempFile.close()
          >>> MLUtils.saveAsLibSVMFile(sc.parallelize(examples), tempFile.name)
          >>> ''.join(sorted(input(glob(tempFile.name + "/part-0000*"))))
          '0.0 1:1.01 2:2.02 3:3.03\\n1.1 1:1.23 3:4.56\\n'
          """
          lines = data.map(lambda p: MLUtils._convert_labeled_point_to_libsvm(p))
          lines.saveAsTextFile(dir)