'Build tensor specifying graph of operations for the seq2seq neural network model.
mode = string, either "train" or "predict"
cell_type = attribute of rnn_cell specifying which RNN cell type to use
cell_size = size for the hidden layer in the RNN cell
num_layers = number of RNN cell layers to use
Return TFLearn model instance.  Use DNN model for this.'

def model(self, mode='train', num_layers=1, cell_size=32, cell_type='BasicLSTMCell', embedding_size=20, learning_rate=0.0001, tensorboard_verbose=0, checkpoint_path=None):

    assert (mode in ['train', 'predict'])
    checkpoint_path = (checkpoint_path or ('%s%ss2s_checkpoint.tfl' % ((self.data_dir or ''), ('/' if self.data_dir else ''))))
    GO_VALUE = (self.out_max_int + 1)
    network = tflearn.input_data(shape=[None, (self.in_seq_len + self.out_seq_len)], dtype=tf.int32, name='XY')
    encoder_inputs = tf.slice(network, [0, 0], [(-1), self.in_seq_len], name='enc_in')
    encoder_inputs = tf.unstack(encoder_inputs, axis=1)
    decoder_inputs = tf.slice(network, [0, self.in_seq_len], [(-1), self.out_seq_len], name='dec_in')
    decoder_inputs = tf.unstack(decoder_inputs, axis=1)
    go_input = tf.multiply(tf.ones_like(decoder_inputs[0], dtype=tf.int32), GO_VALUE)
    decoder_inputs = ([go_input] + decoder_inputs[:(self.out_seq_len - 1)])
    feed_previous = (not (mode == 'train'))
    if (self.verbose > 3):
        print(('feed_previous    =    %s' % str(feed_previous)))
        print(('encoder    inputs:    %s' % str(encoder_inputs)))
        print(('decoder    inputs:    %s' % str(decoder_inputs)))
        print(('len    decoder    inputs:    %s' % len(decoder_inputs)))
    self.n_input_symbols = (self.in_max_int + 1)
    self.n_output_symbols = (self.out_max_int + 2)
    single_cell = getattr(rnn_cell, cell_type)(cell_size, state_is_tuple=True)
    if (num_layers == 1):
        cell = single_cell
    else:
        cell = rnn_cell.MultiRNNCell(([single_cell] * num_layers))
    if (self.seq2seq_model == 'embedding_rnn'):
        (model_outputs, states) = seq2seq.embedding_rnn_seq2seq(encoder_inputs, decoder_inputs, cell, num_encoder_symbols=self.n_input_symbols, num_decoder_symbols=self.n_output_symbols, embedding_size=embedding_size, feed_previous=feed_previous)
    elif (self.seq2seq_model == 'embedding_attention'):
        (model_outputs, states) = seq2seq.embedding_attention_seq2seq(encoder_inputs, decoder_inputs, cell, num_encoder_symbols=self.n_input_symbols, num_decoder_symbols=self.n_output_symbols, embedding_size=embedding_size, num_heads=1, initial_state_attention=False, feed_previous=feed_previous)
    else:
        raise Exception(('[TFLearnSeq2Seq]    Unknown    seq2seq    model    %s' % self.seq2seq_model))
    tf.add_to_collection(((tf.GraphKeys.LAYER_VARIABLES + '/') + 'seq2seq_model'), model_outputs)
    if (self.verbose > 2):
        print(('model    outputs:    %s' % model_outputs))
    network = tf.stack(model_outputs, axis=1)
    if (self.verbose > 2):
        print(('packed    model    outputs:    %s' % network))
    if (self.verbose > 3):
        all_vars = tf.get_collection(tf.GraphKeys.VARIABLES)
        print(('all_vars    =    %s' % all_vars))
    with tf.name_scope('TargetsData'):
        targetY = tf.placeholder(shape=[None, self.out_seq_len], dtype=tf.int32, name='Y')
    network = tflearn.regression(network, placeholder=targetY, optimizer='adam', learning_rate=learning_rate, loss=self.sequence_loss, metric=self.accuracy, name='Y')
    model = tflearn.DNN(network, tensorboard_verbose=tensorboard_verbose, checkpoint_path=checkpoint_path)
    return model
