docstr: Args:
      src_ids (`Variable` of shape `[batch_size, seq_len]`):
          Indices of input sequence tokens in the vocabulary.
      sent_ids (optional, `Variable` of shape `[batch_size, seq_len]`):
          aka token_type_ids, Segment token indices to indicate first and second portions of the inputs.
          if None, assume all tokens come from `segment_a`
      pos_ids(optional, `Variable` of shape `[batch_size, seq_len]`):
          Indices of positions of each input sequence tokens in the position embeddings.
      input_mask(optional `Variable` of shape `[batch_size, seq_len]`):
          Mask to avoid performing attention on the padding token indices of the encoder input.
      attn_bias(optional, `Variable` of shape `[batch_size, seq_len, seq_len] or False`):
          3D version of `input_mask`, if set, overrides `input_mask`; if set not False, will not apply attention mask
      past_cache(optional, tuple of two lists: cached key and cached value,
          each is a list of `Variable`s of shape `[batch_size, seq_len, hidden_size]`):
          cached key/value tensor that will be concated to generated key/value when performing self attention.
          if set, `attn_bias` should not be None.
  Returns:
      pooled (`Variable` of shape `[batch_size, hidden_size]`):
          output logits of pooler classifier
      encoded(`Variable` of shape `[batch_size, seq_len, hidden_size]`):
          output logits of transformer stack
      info (Dictionary):
          addtional middle level info, inclues: all hidden stats, k/v caches.
docstr_tok: ["Args",":","src_ids","(","`","Variable","`","of","shape","`","[","batch_size",",","seq_len","]","`",")",":","Indices","of","input","sequence","tokens","in","the","vocabulary",".","sent_ids","(","optional",",","`","Variable","`","of","shape","`","[","batch_size",",","seq_len","]","`",")",":","aka","token_type_ids",",","Segment","token","indices","to","indicate","first","and","second","portions","of","the","inputs",".","if","None",",","assume","all","tokens","come","from","`","segment_a","`","pos_ids","(","optional",",","`","Variable","`","of","shape","`","[","batch_size",",","seq_len","]","`",")",":","Indices","of","positions","of","each","input","sequence","tokens","in","the","position","embeddings",".","input_mask","(","optional","`","Variable","`","of","shape","`","[","batch_size",",","seq_len","]","`",")",":","Mask","to","avoid","performing","attention","on","the","padding","token","indices","of","the","encoder","input",".","attn_bias","(","optional",",","`","Variable","`","of","shape","`","[","batch_size",",","seq_len",",","seq_len","]","or","False","`",")",":","3D","version","of","`","input_mask","`",",","if","set",",","overrides","`","input_mask","`",";","if","set","not","False",",","will","not","apply","attention","mask","past_cache","(","optional",",","tuple","of","two","lists",":","cached","key","and","cached","value",",","each","is","a","list","of","`","Variable","`","s","of","shape","`","[","batch_size",",","seq_len",",","hidden_size","]","`",")",":","cached","key\/value","tensor","that","will","be","concated","to","generated","key\/value","when","performing","self","attention",".","if","set",",","`","attn_bias","`","should","not","be","None",".","Returns",":","pooled","(","`","Variable","`","of","shape","`","[","batch_size",",","hidden_size","]","`",")",":","output","logits","of","pooler","classifier","encoded","(","`","Variable","`","of","shape","`","[","batch_size",",","seq_len",",","hidden_size","]","`",")",":","output","logits","of","transformer","stack","info","(","Dictionary",")",":","addtional","middle","level","info",",","inclues",":","all","hidden","stats",",","k\/v","caches","."]
code: def forward(
      self,
      src_ids,
      sent_ids=None,
      pos_ids=None,
      input_mask=None,
      attn_bias=None,
      past_cache=None,
      use_causal_mask=False,
  ):
      """
      Args:
          src_ids (`Variable` of shape `[batch_size, seq_len]`):
              Indices of input sequence tokens in the vocabulary.
          sent_ids (optional, `Variable` of shape `[batch_size, seq_len]`):
              aka token_type_ids, Segment token indices to indicate first and second portions of the inputs.
              if None, assume all tokens come from `segment_a`
          pos_ids(optional, `Variable` of shape `[batch_size, seq_len]`):
              Indices of positions of each input sequence tokens in the position embeddings.
          input_mask(optional `Variable` of shape `[batch_size, seq_len]`):
              Mask to avoid performing attention on the padding token indices of the encoder input.
          attn_bias(optional, `Variable` of shape `[batch_size, seq_len, seq_len] or False`):
              3D version of `input_mask`, if set, overrides `input_mask`; if set not False, will not apply attention mask
          past_cache(optional, tuple of two lists: cached key and cached value,
              each is a list of `Variable`s of shape `[batch_size, seq_len, hidden_size]`):
              cached key/value tensor that will be concated to generated key/value when performing self attention.
              if set, `attn_bias` should not be None.
      Returns:
          pooled (`Variable` of shape `[batch_size, hidden_size]`):
              output logits of pooler classifier
          encoded(`Variable` of shape `[batch_size, seq_len, hidden_size]`):
              output logits of transformer stack
          info (Dictionary):
              addtional middle level info, inclues: all hidden stats, k/v caches.
      """
      assert (
          len(src_ids.shape) == 2
      ), "expect src_ids.shape = [batch, sequecen], got %s" % (
          repr(src_ids.shape)
      )
      assert (
          attn_bias is not None if past_cache else True
      ), "if `past_cache` is specified; attn_bias should not be None"
      d_seqlen = P.shape(src_ids)[1]
      if pos_ids is None:
          pos_ids = (
              P.arange(0, d_seqlen, 1, dtype="int32")
              .reshape([1, -1])
              .cast("int64")
          )
      if attn_bias is None:
          if input_mask is None:
              input_mask = P.cast(src_ids != 0, "float32")
          assert len(input_mask.shape) == 2
          input_mask = input_mask.unsqueeze(-1)
          attn_bias = input_mask.matmul(input_mask, transpose_y=True)
          if use_causal_mask:
              sequence = P.reshape(
                  P.arange(0, d_seqlen, 1, dtype="float32") + 1.0,
                  [1, 1, -1, 1],
              )
              causal_mask = (
                  sequence.matmul(1.0 / sequence, transpose_y=True)
                  >= 1.0
              ).cast("float32")
              attn_bias *= causal_mask
      else:
          assert len(attn_bias.shape) == 3, (
              "expect attn_bias tobe rank 3, got %r" % attn_bias.shape
          )
      attn_bias = (1.0 - attn_bias) * -10000.0
      attn_bias = attn_bias.unsqueeze(1).tile(
          [1, self.n_head, 1, 1]
      )  # avoid broadcast =_=
      attn_bias.stop_gradient = True
      if sent_ids is None:
          sent_ids = P.zeros_like(src_ids)
      if self.d_rel_pos:
          rel_pos_ids = self.rel_pos_bias[:d_seqlen, :d_seqlen]
          rel_pos_ids = P.to_tensor(rel_pos_ids, dtype="int64")
          rel_pos_bias = self.rel_pos_bias_emb(rel_pos_ids).transpose(
              [2, 0, 1]
          )
          attn_bias += rel_pos_bias
      src_embedded = self.word_emb(src_ids)
      pos_embedded = self.pos_emb(pos_ids)
      sent_embedded = self.sent_emb(sent_ids)
      embedded = src_embedded + pos_embedded + sent_embedded
  
      embedded = self.dropout(self.ln(embedded))
  
      encoded, hidden_list, cache_list = self.encoder_stack(
          embedded, attn_bias, past_cache=past_cache
      )
      if self.pooler is not None:
          pooled = F.tanh(self.pooler(encoded[:, 0, :]))
      else:
          pooled = None
  
      additional_info = {
          "hiddens": hidden_list,
          "caches": cache_list,
      }
  
      if self.return_additional_info:
          return pooled, encoded, additional_info
      return pooled, encoded
  
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 4 for calling the ErnieModel obj's underlying member method code with example usage: obj.forward(src_ids, sent_ids, pos_ids, input_mask, attn_bias, past_cache, use_causal_mask) and returns: pooled,  encoded, pooled,  encoded,  additional_info