human
I wrote the below code

    logging.info('Reserving    TFSparkNodes    {0}'.format(('w/    TensorBoard' if tensorboard else '')))
    assert (num_ps < num_executors)
    cluster_template = {}
    cluster_template['ps'] = range(num_ps)
    cluster_template['worker'] = range(num_ps, num_executors)
    defaultFS = sc._jsc.hadoopConfiguration().get('fs.defaultFS')
    if (defaultFS.startswith('file://') and (len(defaultFS) > 7) and defaultFS.endswith('/')):
        defaultFS = defaultFS[:(-1)]
    working_dir = os.getcwd()
    server = reservation.Server(num_executors)
    server_addr = server.start()
    logging.info('Starting    TensorFlow    on    executors')
    cluster_meta = {'id': random.getrandbits(64), 'cluster_template': cluster_template, 'num_executors': num_executors, 'default_fs': defaultFS, 'working_dir': working_dir, 'server_addr': server_addr}
    nodeRDD = sc.parallelize(range(num_executors), num_executors)
    def _start():
        nodeRDD.foreachPartition(TFSparkNode.run(map_fun, tf_args, cluster_meta, tensorboard, queues, background=(input_mode == InputMode.SPARK)))
    t = threading.Thread(target=_start)
    t.start()
    logging.info('Waiting    for    TFSparkNodes    to    start')
    cluster_info = server.await_reservations()
    logging.info('All    TFSparkNodes    started')
    tb_url = None
    for node in cluster_info:
        logging.info(node)
        if (node['tb_port'] != 0):
            tb_url = 'http://{0}:{1}'.format(node['host'], node['tb_port'])
    if (tb_url is not None):
        logging.info('========================================================================================')
        logging.info('')
        logging.info('TensorBoard    running    at:                            {0}'.format(tb_url))
        logging.info('')
        logging.info('========================================================================================')
    tb_nodes = set()
    for node in cluster_info:
        node_id = (node['host'], node['ppid'])
        if (node_id in tb_nodes):
            raise...

What's a good function header?
assistant
#Here's a good function header.

def run(sc, map_fun, tf_args, num_executors, num_ps, tensorboard=False, input_mode=InputMode.TENSORFLOW, queues=['input', 'output']):