docstr: Fundamental pretrained Ernie model
docstr_tok: ["Fundamental","pretrained","Ernie","model"]
code: def __init__(self, cfg, name=None):
      """
      Fundamental pretrained Ernie model
      """
      log.debug("init ErnieModel with config: %s" % repr(cfg))
      nn.Layer.__init__(self)
      d_model = cfg["hidden_size"]
      d_emb = cfg.get("emb_size", cfg["hidden_size"])
      d_vocab = cfg["vocab_size"]
      d_pos = cfg["max_position_embeddings"]
      d_sent = cfg.get("sent_type_vocab_size") or cfg["type_vocab_size"]
      self.d_rel_pos = cfg.get("rel_pos_size", None)
      max_seq_len = cfg.get("max_seq_len", 512)
      self.n_head = cfg["num_attention_heads"]
      self.return_additional_info = cfg.get(
          "return_additional_info", False
      )
      initializer = nn.initializer.TruncatedNormal(
          std=cfg["initializer_range"]
      )
      if self.d_rel_pos:
          self.rel_pos_bias = _get_rel_pos_bias(max_seq_len)
  
      self.ln = _build_ln(
          d_model, name=append_name(name, "pre_encoder")
      )
      self.word_emb = nn.Embedding(
          d_vocab,
          d_emb,
          weight_attr=P.ParamAttr(
              name=append_name(name, "word_embedding"),
              initializer=initializer,
          ),
      )
      self.pos_emb = nn.Embedding(
          d_pos,
          d_emb,
          weight_attr=P.ParamAttr(
              name=append_name(name, "pos_embedding"),
              initializer=initializer,
          ),
      )
      self.sent_emb = nn.Embedding(
          d_sent,
          d_emb,
          weight_attr=P.ParamAttr(
              name=append_name(name, "sent_embedding"),
              initializer=initializer,
          ),
      )
      if self.d_rel_pos:
          self.rel_pos_bias_emb = nn.Embedding(
              self.d_rel_pos,
              self.n_head,
              weight_attr=P.ParamAttr(
                  name=append_name(name, "rel_pos_embedding"),
                  initializer=initializer,
              ),
          )
      prob = cfg["hidden_dropout_prob"]
      self.dropout = nn.Dropout(p=prob)
  
      self.encoder_stack = ErnieEncoderStack(
          cfg, append_name(name, "encoder")
      )
      if cfg.get("has_pooler", True):
          self.pooler = _build_linear(
              cfg["hidden_size"],
              cfg["hidden_size"],
              append_name(name, "pooled_fc"),
              initializer,
          )
      else:
          self.pooler = None
      self.train()
  
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 1 to create a new ErnieModel object from inherited base classes: nn, PretrainedModel with example: obj = ErnieModel(cfg, name)