import tensorflow as tf

            if encoder.attend_inputs:
                encoder_outputs.append(encoder_inputs_)
            elif encoder.attend_both:
                encoder_outputs.append(tf.concat([encoder_inputs_, encoder_outputs_], axis=2))
            else:
                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
