code: def flatMap(self, f, preservesPartitioning=False):
          
          return self.mapPartitions(
              lambda p: (e for pp in p for e in f(pp)),
              preservesPartitioning,
          )
docs: Apply function f and flatten.
  
          :param f: mapping function
          :rtype: DStream