def _wrap_with_attention(self, cell, memory, hparams):
    """Wraps RNN cell and memory with attention."""
    # Get decoding attention mechanism.
    with tf.variable_scope("decoding_attention", reuse=tf.AUTO_REUSE):
      attention_mechanism = attention_wrappers.FixedMemoryLuongAttention(
          num_units=hparams.hidden_size,
          memory=memory,
          memory_sequence_length=None,
          scale=True,
          name="FixedMemoryAttention")

    # Wrap RNN cell.
    wrapped_cell = attention_wrappers.FixedMemoryAttentionWrapper(
        cell, attention_mechanism,
        attention_layer_size=None,
        cell_input_fn=lambda inputs, attention: inputs,
        output_attention=True)

    return wrapped_cell
Wraps RNN cell and memory with attention.
language/labs/consistent_zero_shot_nmt/modules/decoders.py