code: def _create_attention_images_summary(final_context_state):
      """create attention image and attention summary."""
      attention_images = final_context_state.alignment_history.stack()
      # Reshape to (batch, src_seq_len, tgt_seq_len,1)
      attention_images = tf.expand_dims(
          tf.transpose(attention_images, [1, 2, 0]), -1
      )
      # Scale to range [0, 255]
      attention_images *= 255
      attention_summary = tf.summary.image(
          "attention_images", attention_images
      )
      return attention_summary
  
file_path: nlp-architect/examples/sparse_gnmt/gnmt/attention_model.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
  from .None import model
  from .None import model_helper
label_desc: Use image node_id 2 for calling a global function with example usage: _create_attention_images_summary(final_context_state) and returns: attention_summary