'Train model, with specified number of epochs, and dataset size.
Use specified model, or create one if not provided.  Load initial weights from file weights_input_fn,
if provided. validation_set specifies what to use for the validation.
Returns logits for prediction, as an numpy array of shape [out_seq_len, n_output_symbols].'

def train(self, num_epochs=20, num_points=100000, model=None, model_params=None, weights_input_fn=None, validation_set=0.1, snapshot_step=5000, batch_size=128, weights_output_fn=None):

    (trainXY, trainY) = self.generate_trainig_data(num_points)
    print(("[TFLearnSeq2Seq]    Training    on    %d    point    dataset    (pattern    '%s'),    with    %d    epochs" % (num_points, self.sequence_pattern.PATTERN_NAME, num_epochs)))
    if (self.verbose > 1):
        print(('        model    parameters:    %s' % json.dumps(model_params, indent=4)))
    model_params = (model_params or {})
    model = (model or self.setup_model('train', model_params, weights_input_fn))
    model.fit(trainXY, trainY, n_epoch=num_epochs, validation_set=validation_set, batch_size=batch_size, shuffle=True, show_metric=True, snapshot_step=snapshot_step, snapshot_epoch=False, run_id='TFLearnSeq2Seq')
    print('Done!')
    if (weights_output_fn is not None):
        weights_output_fn = self.canonical_weights_fn(weights_output_fn)
        model.save(weights_output_fn)
        print(('Saved    %s' % weights_output_fn))
        self.weights_output_fn = weights_output_fn
    return model
