code: def forward(self, inputs, targets=None, batch_max_length=25):
      batch_size = inputs.shape[0]
      num_steps = batch_max_length
  
      hidden = (
          paddle.zeros((batch_size, self.hidden_size)),
          paddle.zeros((batch_size, self.hidden_size)),
      )
      output_hiddens = []
  
      if targets is not None:
          for i in range(num_steps):
              # one-hot vectors for a i-th char
              char_onehots = self._char_to_onehot(
                  targets[:, i], onehot_dim=self.num_classes
              )
              hidden, alpha = self.attention_cell(
                  hidden, inputs, char_onehots
              )
  
              hidden = (hidden[1][0], hidden[1][1])
              output_hiddens.append(paddle.unsqueeze(hidden[0], axis=1))
          output = paddle.concat(output_hiddens, axis=1)
          probs = self.generator(output)
  
      else:
          targets = paddle.zeros(shape=[batch_size], dtype="int32")
          probs = None
          char_onehots = None
          alpha = None
  
          for i in range(num_steps):
              char_onehots = self._char_to_onehot(
                  targets, onehot_dim=self.num_classes
              )
              hidden, alpha = self.attention_cell(
                  hidden, inputs, char_onehots
              )
              probs_step = self.generator(hidden[0])
              hidden = (hidden[1][0], hidden[1][1])
              if probs is None:
                  probs = paddle.unsqueeze(probs_step, axis=1)
              else:
                  probs = paddle.concat(
                      [probs, paddle.unsqueeze(probs_step, axis=1)],
                      axis=1,
                  )
  
              next_input = probs_step.argmax(axis=1)
  
              targets = next_input
      if not self.training:
          probs = paddle.nn.functional.softmax(probs, axis=2)
      return probs
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import paddle
  import paddle.nn
  import paddle.nn.functional
  import numpy
label_desc: Use image node_id 3 for calling the AttentionLSTM obj's underlying member method code with example usage: obj.forward(inputs, targets, batch_max_length) and returns: probs