code: def _do_python_join(rdd, other, numPartitions, dispatch):
      vs = rdd.mapValues(lambda v: (1, v))
      ws = other.mapValues(lambda v: (2, v))
      return (
          vs.union(ws)
          .groupByKey(numPartitions)
          .flatMapValues(lambda x: dispatch(x.__iter__()))
      )
  
file_path: spark/python/pyspark/join.py
imports: from functools import reduce
  from pyspark.resultiterable import ResultIterable
label_desc: Use image node_id 1 for calling a global function with example usage: _do_python_join(rdd, other, numPartitions, dispatch) and returns: vs