'Basic setup. The actual TensorFlow graph is constructed in build().
Args:
config: Object containing configuration parameters.
mode: "train", "eval" or "encode".
input_reader: Subclass of tf.ReaderBase for reading the input serialized
tf.Example protocol buffers. Defaults to TFRecordReader.
Raises:
ValueError: If mode is invalid.'

def __init__(self, config, mode='train', input_reader=None):

    if (mode not in ['train', 'eval', 'encode']):
        raise ValueError(('Unrecognized    mode:    %s' % mode))
    self.config = config
    self.mode = mode
    self.reader = (input_reader if input_reader else tf.TFRecordReader())
    self.uniform_initializer = tf.random_uniform_initializer(minval=(- self.config.uniform_init_scale), maxval=self.config.uniform_init_scale)
    self.encode_ids = None
    self.decode_pre_ids = None
    self.decode_post_ids = None
    self.encode_mask = None
    self.decode_pre_mask = None
    self.decode_post_mask = None
    self.encode_emb = None
    self.decode_pre_emb = None
    self.decode_post_emb = None
    self.thought_vectors = None
    self.target_cross_entropy_losses = []
    self.target_cross_entropy_loss_weights = []
    self.total_loss = None
