class_docstr: Ernie Model for sequence to sequence generation.
class_docstr_tok: ["Ernie","Model","for","sequence","to","sequence","generation","."]
docstr: Args
      tgt_labels(`Variable` of shape [batch_size, seqlen] or [batch, seqlen, vocab_size]):
          ground trouth target sequence id (hard label) or distribution (soft label)
      tgt_pos(`Variable` of shape [n_targets, 2]):
          index of tgt_labels in `src_ids`, can be obtained from `fluid.layers.where(src_ids==mask_id)`
      encoder_only(Bool):
          if set, will not return loss, logits_2d
  Returns:
      loss(`Variable` of shape []):
          cross entropy loss mean over every target label. if `encode_only`, returns None.
      logits(`Variable` of shape [n_targets, vocab_size]):
          logits for every targets. if `encode_only`, returns None.
      info(Dictionary): see `ErnieModel`
docstr_tok: ["Args","tgt_labels","(","`","Variable","`","of","shape","[","batch_size",",","seqlen","]","or","[","batch",",","seqlen",",","vocab_size","]",")",":","ground","trouth","target","sequence","id","(","hard","label",")","or","distribution","(","soft","label",")","tgt_pos","(","`","Variable","`","of","shape","[","n_targets",",","2","]",")",":","index","of","tgt_labels","in","`","src_ids","`",",","can","be","obtained","from","`","fluid.layers.where","(","src_ids==mask_id",")","`","encoder_only","(","Bool",")",":","if","set",",","will","not","return","loss",",","logits_2d","Returns",":","loss","(","`","Variable","`","of","shape","[","]",")",":","cross","entropy","loss","mean","over","every","target","label",".","if","`","encode_only","`",",","returns","None",".","logits","(","`","Variable","`","of","shape","[","n_targets",",","vocab_size","]",")",":","logits","for","every","targets",".","if","`","encode_only","`",",","returns","None",".","info","(","Dictionary",")",":","see","`","ErnieModel","`"]
code: def forward(self, *args, **kwargs):
      """
      Args
          tgt_labels(`Variable` of shape [batch_size, seqlen] or [batch, seqlen, vocab_size]):
              ground trouth target sequence id (hard label) or distribution (soft label)
          tgt_pos(`Variable` of shape [n_targets, 2]):
              index of tgt_labels in `src_ids`, can be obtained from `fluid.layers.where(src_ids==mask_id)`
          encoder_only(Bool):
              if set, will not return loss, logits_2d
      Returns:
          loss(`Variable` of shape []):
              cross entropy loss mean over every target label. if `encode_only`, returns None.
          logits(`Variable` of shape [n_targets, vocab_size]):
              logits for every targets. if `encode_only`, returns None.
          info(Dictionary): see `ErnieModel`
      """
      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, *args, **kwargs)
      if encode_only:
          return None, None, info
      if tgt_labels is None or tgt_pos is None:
          encoded = self.act(self.mlm(encoded))
          encoded = self.mlm_ln(encoded)
          logits = (
              encoded.matmul(self.word_emb.weight, transpose_y=True)
              + self.mlm_bias
          )
          output_ids = logits.cast("float32").argmax(-1)
          return output_ids, logits, info
      else:
          encoded_2d = encoded.gather_nd(tgt_pos)
          encoded_2d = self.act(self.mlm(encoded_2d))
          encoded_2d = self.mlm_ln(encoded_2d)
          logits_2d = (
              encoded_2d.matmul(self.word_emb.weight, transpose_y=True)
              + self.mlm_bias
          )
          assert len(tgt_labels.shape) == 2, (
              "expect 2d label, got %r" % tgt_labels
          )
  
          loss = F.cross_entropy(logits_2d, tgt_labels, soft_label=True)
          return loss, logits_2d, info
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import json
  import logging
  import math
  import six
  import numpy
  import paddle
  from paddle import nn
  from paddle.nn import functional
  from disco_diffusion_ernievil_base.vit_b_16x.ernievil2.transformers.file_utils import _fetch_from_remote, add_docstring
label_desc: Use image node_id 2 for calling the ErnieModelForGeneration obj's underlying member method code with example usage: obj.forward() and returns: None,  None,  info, output_ids,  logits,  info, loss,  logits_2d,  info