code: def forward(self, image, text_length, text_input, attention_map=None):
      if image.shape[1] == 3:
          R = image[:, 0:1, :, :]
          G = image[:, 1:2, :, :]
          B = image[:, 2:3, :, :]
          image = 0.299 * R + 0.587 * G + 0.114 * B
  
      conv_feature = self.encoder(image)  # batch, 1024, 8, 32
      max_length = max(text_length)
      text_input = text_input[:, :max_length]
  
      text_embedding = self.embedding_word_with_upperword(
          text_input
      )  # batch, text_max_length, 512
      postion_embedding = self.pe(
          paddle.zeros(text_embedding.shape)
      )  # batch, text_max_length, 512
      text_input_with_pe = paddle.concat(
          [text_embedding, postion_embedding], 2
      )  # batch, text_max_length, 1024
      batch, seq_len, _ = text_input_with_pe.shape
  
      text_input_with_pe, word_attention_map = self.decoder(
          text_input_with_pe, conv_feature
      )
  
      word_decoder_result = self.generator_word_with_upperword(
          text_input_with_pe
      )
  
      if self.training:
          total_length = paddle.sum(text_length)
          probs_res = paddle.zeros(
              [total_length, self.get_alphabet_len()]
          )
          start = 0
  
          for index, length in enumerate(text_length):
              length = int(length.numpy())
              probs_res[
                  start : start + length, :
              ] = word_decoder_result[index, 0 : 0 + length, :]
  
              start = start + length
  
          return probs_res, word_attention_map, None
      else:
          return word_decoder_result
  
imports: import copy
  import math
  import paddle
  import paddle.nn
  import paddle.nn.functional
label_desc: Use image node_id 3 for calling the Transformer obj's underlying member method code with example usage: obj.forward(image, text_length, text_input, attention_map) and returns: probs_res,  word_attention_map,  None, word_decoder_result