class_docstr: The original attention from Badhanau et al. (2014)
  https://arxiv.org/abs/1409.0473 based on a Multi-Layer Perceptron.
  
  The attention score between position i in the encoder and position j in the
  decoder is:
  alpha_ij = V_a * tanh(W_ae * enc_i + W_ad * dec_j + b_a)
docstr: The expected input dimensions are:
  
  decoder_state: bsz x decoder_hidden_state_dim
  source_hids: src_len x bsz x context_dim
  src_lengths: bsz
code: def forward(self, decoder_state, source_hids, src_lengths):
      """The expected input dimensions are:
  
      decoder_state: bsz x decoder_hidden_state_dim
      source_hids: src_len x bsz x context_dim
      src_lengths: bsz
      """
      src_len, bsz, _ = source_hids.size()
      # (src_len*bsz) x context_dim (to feed through linear)
      flat_source_hids = source_hids.view(-1, self.context_dim)
      # (src_len*bsz) x attention_dim
      encoder_component = self.encoder_proj(flat_source_hids)
      # src_len x bsz x attention_dim
      encoder_component = encoder_component.view(
          src_len, bsz, self.attention_dim
      )
      # 1 x bsz x attention_dim
      decoder_component = self.decoder_proj(decoder_state).unsqueeze(0)
      # Sum with broadcasting and apply the non linearity
      # src_len x bsz x attention_dim
      hidden_att = F.tanh(
          (decoder_component + encoder_component).view(
              -1, self.attention_dim
          )
      )
      # Project onto the reals to get attentions scores (bsz x src_len)
      attn_scores = self.to_scores(hidden_att).view(src_len, bsz).t()
  
      # Mask + softmax (src_len x bsz)
      normalized_masked_attn_scores = attention_utils.masked_softmax(
          attn_scores, src_lengths, self.src_length_masking
      ).t()
  
      # Sum weighted sources (bsz x context_dim)
      attn_weighted_context = (
          source_hids * normalized_masked_attn_scores.unsqueeze(2)
      ).sum(0)
  
      return attn_weighted_context, normalized_masked_attn_scores
  
file_path: translate/pytorch_translate/attention/mlp_attention.py
imports: import numpy
  import torch
  import torch.nn.functional
  from pytorch_translate.attention import attention_utils, BaseAttention, register_attention
  from pytorch_translate.common_layers import Linear
label_desc: Use image node_id 3 for calling the MLPAttention obj's underlying member method code with example usage: obj.forward(decoder_state, source_hids, src_lengths) and returns: attn_weighted_context,  normalized_masked_attn_scores