human
I wrote the below code

    num_workers = len(cluster_spec.as_dict()['worker'])
    num_parameter_servers = len(cluster_spec.as_dict()['ps'])
    if (FLAGS.num_replicas_to_aggregate == (-1)):
        num_replicas_to_aggregate = num_workers
    else:
        num_replicas_to_aggregate = FLAGS.num_replicas_to_aggregate
    assert ((num_workers > 0) and (num_parameter_servers > 0)), '    num_workers    and    num_parameter_servers    must    be    >    0.'
    is_chief = (FLAGS.task_id == 0)
    with tf.device(('/job:worker/task:%d' % FLAGS.task_id)):
        with slim.scopes.arg_scope([slim.variables.variable, slim.variables.global_step], device=slim.variables.VariableDeviceChooser(num_parameter_servers)):
            global_step = slim.variables.global_step()
            num_batches_per_epoch = (dataset.num_examples_per_epoch() / FLAGS.batch_size)
            decay_steps = int(((num_batches_per_epoch * FLAGS.num_epochs_per_decay) / num_replicas_to_aggregate))
            lr = tf.train.exponential_decay(FLAGS.initial_learning_rate, global_step, decay_steps, FLAGS.learning_rate_decay_factor, staircase=True)
            tf.summary.scalar('learning_rate', lr)
            opt = tf.train.RMSPropOptimizer(lr, RMSPROP_DECAY, momentum=RMSPROP_MOMENTUM, epsilon=RMSPROP_EPSILON)
            if (FLAGS.input_mode == 'spark'):
                def feed_dict(mgr, batch_size):
                    tmp = TFNode.next_batch(mgr, batch_size)
                    tfrecords = []
                    for elem in tmp:
                        tfrecords.append(str(elem[0]))
                    return tfrecords
                batch = tf.placeholder(tf.string, [(FLAGS.batch_size / FLAGS.num_preprocess_threads)])
                examples = tf.unpack(batch)
                (images, labels) = ([], [])
                for example_serialized in examples:
                    for thread_id in range(FLAGS.num_preprocess_threads):
                        (image_buffer, label_index, bbox, _) = image_processing.parse_example_proto(example_serialized)
                       ...

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

def train(target, dataset, cluster_spec, ctx):