'"Creates a Trainer.
Args:
cluster: A tf.train.ClusterSpec if the execution is distributed.
None otherwise.
task: A TaskSpec describing the job type and the task index.'

def __init__(self, cluster, task, train_dir, model, reader, model_exporter, log_device_placement=True, max_steps=None, export_model_steps=1000):

    self.cluster = cluster
    self.task = task
    self.is_master = ((task.type == 'master') and (task.index == 0))
    self.train_dir = train_dir
    self.config = tf.ConfigProto(allow_soft_placement=True, log_device_placement=log_device_placement)
    self.model = model
    self.reader = reader
    self.model_exporter = model_exporter
    self.max_steps = max_steps
    self.max_steps_reached = False
    self.export_model_steps = export_model_steps
    self.last_model_export_step = 0
