'Starts a server if the execution is distributed.'

def start_server_if_distributed(self):

    if self.cluster:
        logging.info('%s:    Starting    trainer    within    cluster    %s.', task_as_string(self.task), self.cluster.as_dict())
        server = start_server(self.cluster, self.task)
        target = server.target
        device_fn = tf.train.replica_device_setter(ps_device='/job:ps', worker_device=('/job:%s/task:%d' % (self.task.type, self.task.index)), cluster=self.cluster)
    else:
        target = ''
        device_fn = ''
    return (target, device_fn)
