code: def forward(self, src_ids, *args, **kwargs):
      tgt_labels = kwargs.pop("tgt_labels", None)
      tgt_pos = kwargs.pop("tgt_pos", None)
      encode_only = kwargs.pop("encode_only", False)
      _, encoded, info = ErnieModel.forward(
          self, src_ids, *args, **kwargs
      )
      if encode_only:
          return None, None, info
      elif tgt_labels is None:
          encoded = self.mlm(encoded)
          encoded = self.mlm_ln(encoded)
          logits = (
              L.matmul(encoded, self.word_emb.weight, transpose_y=True)
              + self.mlm_bias
          )
          output_ids = L.argmax(logits, -1)
          return output_ids, logits, info
      else:
          encoded_2d = L.gather_nd(encoded, tgt_pos)
          encoded_2d = self.mlm(encoded_2d)
          encoded_2d = self.mlm_ln(encoded_2d)
          logits_2d = (
              L.matmul(
                  encoded_2d, self.word_emb.weight, transpose_y=True
              )
              + self.mlm_bias
          )
          if len(tgt_labels.shape) == 1:
              tgt_labels = L.reshape(tgt_labels, [-1, 1])
  
          loss = L.reduce_mean(
              L.softmax_with_cross_entropy(
                  logits_2d,
                  tgt_labels,
                  soft_label=(tgt_labels.shape[-1] != 1),
              )
          )
          return loss, logits_2d, info
  
file_path: PaddleHub/modules/text/text_generation/reading_pictures_writing_poems_for_midautumn/MidAutumnPoetry/model/modeling_ernie_gen.py
imports: import paddle.fluid
  import paddle.fluid.layers
  from .modeling_ernie import ErnieModel
  from .modeling_ernie import _build_linear, _build_ln, append_name
label_desc: Use image node_id 2 for calling the ErnieModelForGeneration obj's underlying member method code with example usage: obj.forward(src_ids) and returns: None,  None,  info, output_ids,  logits,  info, loss,  logits_2d,  info