docstr: Parameters
  ----------
  cfg
      Configuration
  use_pooler
      Whether to output the pooled feature
  
  Returns
  -------
  ret
      The constructed BertModel
docstr_tok: ["Parameters","--","--","--","--","--","cfg","Configuration","use_pooler","Whether","to","output","the","pooled","feature","Returns","--","--","--","-","ret","The","constructed","BertModel"]
code: def from_cfg(cls, cfg, use_pooler=True) -> "BertModel":
      """
  
      Parameters
      ----------
      cfg
          Configuration
      use_pooler
          Whether to output the pooled feature
  
      Returns
      -------
      ret
          The constructed BertModel
      """
      cfg = BertModel.get_cfg().clone_merge(cfg)
      assert cfg.VERSION == 1, "Wrong version!"
      return cls(
          vocab_size=cfg.MODEL.vocab_size,
          units=cfg.MODEL.units,
          hidden_size=cfg.MODEL.hidden_size,
          num_layers=cfg.MODEL.num_layers,
          num_heads=cfg.MODEL.num_heads,
          max_length=cfg.MODEL.max_length,
          hidden_dropout_prob=cfg.MODEL.hidden_dropout_prob,
          attention_dropout_prob=cfg.MODEL.attention_dropout_prob,
          num_token_types=cfg.MODEL.num_token_types,
          pos_embed_type=cfg.MODEL.pos_embed_type,
          activation=cfg.MODEL.activation,
          layer_norm_eps=cfg.MODEL.layer_norm_eps,
          use_pooler=use_pooler,
          layout=cfg.MODEL.layout,
          compute_layout=cfg.MODEL.compute_layout,
      )
  
imports: import logging
  import torch
  from ..attention_cell import gen_self_attn_mask
  from .transformer import TransformerEncoderLayer
  from ..layers import get_activation, sequence_mask
  from ...utils.registry import Registry
  from ...models.bert import bert_cfg_reg
label_desc: Use image node_id 7 for calling the BertModel obj's underlying member method code with example usage: obj.from_cfg(cls, cfg, use_pooler) and returns: cls