import tensorflow as tf

Train RNN graph for multiple series
"""
def train_rnn_multi(raw_data_x, raw_data_y, val_data_x, val_data_y, timeindex_train, timeindex_val, g, num_epochs, num_steps, batch_size, input_prob, output_prob, state_prob, epoch_before_val = 50, max_checks_without_progress=50,epoch_overlap=None, verbose=True, save=False):

    with tf.Session() as sess:
        "initialize the variables"
        sess.run(tf.global_variables_initializer())


        "see the trainable variables"
#        print("The trainable variables are:")
        variable_names = [v.name for v in tf.trainable_variables()]
        variable_shapes = [v.get_shape() for v in tf.trainable_variables()]
        parameter_num = 0
        for name, shape in zip(variable_names, variable_shapes):
#            print('{}\nShape: {}'.format(name, shape))
            parameter_num += shape[0]*shape[1] if np.size(shape)>1 else shape[0]

        "train the graph"
        training_losses = []
        val_losses = []
        #set early_stopping cretirion
        checks_without_progress = 0
        best_loss = np.infty
