import tensorflow as tf

                encoder_outputs.append(encoder_outputs_)

            encoder_states.append(encoder_state_)
            new_encoder_input_length.append(encoder_input_length_)

    encoder_state = tf.concat(encoder_states, 1)
    return encoder_outputs, encoder_state, new_encoder_input_length


def compute_energy(hidden, state, encoder, time=None, input_length=None, prev_weights=None, **kwargs):
    batch_size = tf.shape(hidden)[0]
    time_steps = tf.shape(hidden)[1]

    if encoder.attn_keep_prob is not None:
        state_noise_shape = [1, tf.shape(state)[1]] if encoder.pervasive_dropout else None
        state = tf.nn.dropout(state, keep_prob=encoder.attn_keep_prob, noise_shape=state_noise_shape)
        hidden_noise_shape = [1, 1, tf.shape(hidden)[2]] if encoder.pervasive_dropout else None
        hidden = tf.nn.dropout(hidden, keep_prob=encoder.attn_keep_prob, noise_shape=hidden_noise_shape)

    if encoder.mult_attn:
        state = dense(state, encoder.attn_size, use_bias=False, name='state')
        hidden = dense(hidden, encoder.attn_size, use_bias=False, name='hidden')
        return tf.einsum('ijk,ik->ij', hidden, state)

    y = dense(state, encoder.attn_size, use_bias=not encoder.layer_norm, name='W_a')
    y = tf.expand_dims(y, axis=1)

    if encoder.layer_norm:
        y = tf.contrib.layers.layer_norm(y, scope='layer_norm_state')
        hidden = tf.contrib.layers.layer_norm(hidden, center=False, scope='layer_norm_hidden')
