class_docstr: ernie model 
class_docstr_tok: ["ernie","model"]
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.
      task_ids(optional `Variable` of shape `[batch_size, seq_len]`):
          task type for pre_train task type
      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",".","task_ids","(","optional","`","Variable","`","of","shape","`","[","batch_size",",","seq_len","]","`",")",":","task","type","for","pre_train","task","type","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,
      task_ids=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.
          task_ids(optional `Variable` of shape `[batch_size, seq_len]`):
              task type for pre_train task type
          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, sequence], got %s" % (
          repr(src_ids.shape)
      )
      assert (
          attn_bias is not None if past_cache else True
      ), "if `past_cache` specified; attn_bias must not be None"
      d_seqlen = paddle.shape(src_ids)[1]
      if pos_ids is None:
          pos_ids = (
              paddle.arange(0, d_seqlen, 1, dtype="int32")
              .reshape([1, -1])
              .cast("int64")
          )
  
      if attn_bias is None:
          if input_mask is None:
              input_mask = paddle.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 = paddle.reshape(
                  paddle.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 =_=
  
      if sent_ids is None:
          sent_ids = paddle.zeros_like(src_ids)
  
      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 = src_embedded + pos_embedded
      if self._use_sent_id:
          sent_embedded = self.sent_emb(sent_ids)
          embedded = embedded + sent_embedded
      if self._use_task_id:
          task_embeded = self.task_emb(task_ids)
          embedded = embedded + task_embeded
  
      self._checkpoints.append(embedded.name)
      embedded = self.dropout(self.ln(embedded))
  
      (
          encoded,
          hidden_list,
          cache_list,
          checkpoint_name,
      ) = self.encoder_stack(
          embedded,
          attn_bias,
          past_cache=past_cache,
          key_tag=self.key_tag,
      )
  
      self._checkpoints.extend(checkpoint_name)
      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: import logging
  import re
  import time
  import paddle
  from paddle import nn
  from paddle.nn import functional
label_desc: Use image node_id 5 for calling the ErnieModel obj's underlying member method code with example usage: obj.forward(src_ids, sent_ids, pos_ids, input_mask, task_ids, attn_bias, past_cache, use_causal_mask) and returns: pooled,  encoded, pooled,  encoded,  additional_info