code: def forward(
      self,
      cnn_features,
      cnn_features_trans,
      hidden,
      alpha_sum,
      image_mask=None,
  ):
      query = self.hidden_weight(hidden)
      alpha_sum_trans = self.attention_conv(alpha_sum)
      coverage_alpha = self.attention_weight(
          paddle.transpose(alpha_sum_trans, [0, 2, 3, 1])
      )
      alpha_score = paddle.tanh(
          paddle.unsqueeze(query, [1, 2])
          + coverage_alpha
          + paddle.transpose(cnn_features_trans, [0, 2, 3, 1])
      )
      energy = self.alpha_convert(alpha_score)
      energy = energy - energy.max()
      energy_exp = paddle.exp(paddle.squeeze(energy, -1))
  
      if image_mask is not None:
          energy_exp = energy_exp * paddle.squeeze(image_mask, 1)
      alpha = energy_exp / (
          paddle.unsqueeze(
              paddle.sum(paddle.sum(energy_exp, -1), -1), [1, 2]
          )
          + 1e-10
      )
      alpha_sum = paddle.unsqueeze(alpha, 1) + alpha_sum
      context_vector = paddle.sum(
          paddle.sum((paddle.unsqueeze(alpha, 1) * cnn_features), -1),
          -1,
      )
  
      return context_vector, alpha, alpha_sum
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import paddle.nn
  import paddle
  import math
label_desc: Use image node_id 2 for calling the Attention obj's underlying member method code with example usage: obj.forward(cnn_features, cnn_features_trans, hidden, alpha_sum, image_mask) and returns: context_vector,  alpha,  alpha_sum