import tensorflow as tf

            else:
                gru=tf.nn.rnn_cell.GRUCell(state_size)
                cell_drop=tf.contrib.rnn.DropoutWrapper(gru,variational_recurrent=True,dtype=tf.float32, input_size=num_input,input_keep_prob=input_prob,state_keep_prob=state_prob)

        else:
            if activation == 'linear':
                cell_basic = tf.contrib.rnn.BasicRNNCell(state_size,activation=tf.identity)
                cell_drop=tf.contrib.rnn.DropoutWrapper(cell_basic,variational_recurrent=True,dtype=tf.float32, input_size=num_input,input_keep_prob=input_prob,state_keep_prob=state_prob)

            elif activation == 'relu':
                cell_basic = tf.contrib.rnn.BasicRNNCell(state_size, activation=tf.nn.relu)
                cell_drop = tf.contrib.rnn.DropoutWrapper(cell_basic, variational_recurrent=True, dtype=tf.float32,
                                                          input_size=num_input, input_keep_prob=input_prob,
                                                          state_keep_prob=state_prob)
            else: #tanh by default
                cell_basic = tf.contrib.rnn.BasicRNNCell(state_size)
                cell_drop = tf.contrib.rnn.DropoutWrapper(cell_basic, variational_recurrent=True, dtype=tf.float32,
                                                          input_size=num_input, input_keep_prob=input_prob,
                                                          state_keep_prob=state_prob)

        return cell_drop


    """Wrap the cell in multilayer"""
    cell=tf.nn.rnn_cell.MultiRNNCell([get_a_cell(state_size,input_prob,state_prob,input_size_x if layer==0 else state_size) for layer in range(num_layers)],state_is_tuple=True)
    cell=tf.nn.rnn_cell.DropoutWrapper(cell,variational_recurrent=True,dtype=tf.float32,input_size=input_size_x,output_keep_prob=output_prob)
    init_state = cell.zero_state(batch_size, dtype=tf.float32)

    """Build dynamic graph"""
    rnn_outputs, final_state = tf.nn.dynamic_rnn(cell=cell, inputs=rnn_inputs,initial_state=init_state)
