'Long short-term memory cell with attention (LSTMA).'

def call(self, inputs, state):

    if (not isinstance(state, AttentionTuple)):
        raise TypeError('State    must    be    of    type    AttentionTuple')
    (state, attns) = state
    attn_states = self._attn_states
    attn_length = attn_states.get_shape()[1].value
    if (attn_length is None):
        attn_length = tf.shape(attn_states)[1]
    input_size = self._input_size
    if (input_size is None):
        input_size = inputs.get_shape().as_list()[1]
    if (attns is not None):
        inputs = tf.layers.dense(tf.concat([inputs, attns], axis=1), input_size)
    (lstm_output, new_state) = self._cell(inputs, state)
    new_state_cat = tf.concat(nest.flatten(new_state), 1)
    new_attns = self._attention(new_state_cat, attn_states, attn_length)
    with tf.variable_scope('attn_output_projection'):
        output = tf.layers.dense(tf.concat([lstm_output, new_attns], axis=1), self._attn_size)
    new_state = AttentionTuple(new_state, new_attns)
    return (output, new_state)
