code: def forward(self, input, source_hids, encoder_padding_mask):
      # input: bsz x input_embed_dim
      # source_hids: srclen x bsz x source_embed_dim
  
      # x: bsz x source_embed_dim
      x = self.input_proj(input)
  
      # compute attention
      attn_scores = (source_hids * x.unsqueeze(0)).sum(dim=2)
  
      # don't attend over padding
      if encoder_padding_mask is not None:
          attn_scores = (
              attn_scores.float()
              .masked_fill_(encoder_padding_mask, float("-inf"))
              .type_as(attn_scores)
          )  # FP16 support: cast to float and back
  
      attn_scores = F.softmax(attn_scores, dim=0)  # srclen x bsz
  
      # sum weighted sources
      x = (attn_scores.unsqueeze(2) * source_hids).sum(dim=0)
  
      x = torch.tanh(self.output_proj(torch.cat((x, input), dim=1)))
      return x, attn_scores
  
imports: from typing import Dict, List, Optional, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from fairseq import utils
  from fairseq.models import FairseqEncoder, FairseqEncoderDecoderModel, FairseqIncrementalDecoder, register_model, register_model_architecture
  from fairseq.modules import AdaptiveSoftmax, FairseqDropout
  from torch import Tensor
label_desc: Use image node_id 2 for calling the AttentionLayer obj's underlying member method code with example usage: obj.forward(input, source_hids, encoder_padding_mask) and returns: x,  attn_scores