docstr: Parameters
  ----------
  cfg
      The configuration
  dtype
      Data type of the loaded config
  extract_feature
      Whether to only extract feature.
      If so, the output of the layer will be contextual embeddings or the
      contextual embedding + pooled output
  use_pooler
      Whether to use pooler
  classifier_activation
      Whether to use the classifier activation
  
  Returns
  -------
  model
      The initialized BartModel
docstr_tok: ["Parameters","--","--","--","--","--","cfg","The","configuration","dtype","Data","type","of","the","loaded","config","extract_feature","Whether","to","only","extract","feature",".","If","so",",","the","output","of","the","layer","will","be","contextual","embeddings","or","the","contextual","embedding","+","pooled","output","use_pooler","Whether","to","use","pooler","classifier_activation","Whether","to","use","the","classifier","activation","Returns","--","--","--","-","model","The","initialized","BartModel"]
code: def from_cfg(
      cls,
      cfg,
      dtype=None,
      extract_feature=False,
      use_pooler=True,
      classifier_activation=False,
  ):
      """
  
      Parameters
      ----------
      cfg
          The configuration
      dtype
          Data type of the loaded config
      extract_feature
          Whether to only extract feature.
          If so, the output of the layer will be contextual embeddings or the
          contextual embedding + pooled output
      use_pooler
          Whether to use pooler
      classifier_activation
          Whether to use the classifier activation
  
      Returns
      -------
      model
          The initialized BartModel
      """
      cfg = cls.get_cfg().clone_merge(cfg)
      embed_initializer = mx.init.create(*cfg.INITIALIZER.embed)
      weight_initializer = mx.init.create(*cfg.INITIALIZER.weight)
      bias_initializer = mx.init.create(*cfg.INITIALIZER.bias)
      if dtype is None:
          dtype = cfg.MODEL.dtype
      return cls(
          src_vocab_size=cfg.MODEL.vocab_size,
          tgt_vocab_size=cfg.MODEL.vocab_size,
          max_src_length=cfg.MODEL.max_src_length,
          max_tgt_length=cfg.MODEL.max_tgt_length,
          scale_embed=cfg.MODEL.scale_embed,
          pos_embed_type=cfg.MODEL.pos_embed_type,
          shared_embed=cfg.MODEL.shared_embed,
          tie_weights=cfg.MODEL.tie_weights,
          data_norm=cfg.MODEL.data_norm,
          extract_feature=extract_feature,
          use_pooler=use_pooler,
          classifier_activation=classifier_activation,
          attention_dropout=cfg.MODEL.attention_dropout,
          activation_dropout=cfg.MODEL.activation_dropout,
          dropout=cfg.MODEL.dropout,
          pooler_activation=cfg.MODEL.pooler_activation,
          layer_norm_eps=cfg.MODEL.layer_norm_eps,
          enc_num_layers=cfg.MODEL.ENCODER.num_layers,
          enc_units=cfg.MODEL.ENCODER.units,
          enc_num_heads=cfg.MODEL.ENCODER.num_heads,
          enc_hidden_size=cfg.MODEL.ENCODER.hidden_size,
          enc_recurrent=cfg.MODEL.ENCODER.recurrent,
          enc_activation=cfg.MODEL.ENCODER.activation,
          enc_pre_norm=cfg.MODEL.ENCODER.pre_norm,
          dec_num_layers=cfg.MODEL.DECODER.num_layers,
          dec_units=cfg.MODEL.DECODER.units,
          dec_num_heads=cfg.MODEL.DECODER.num_heads,
          dec_hidden_size=cfg.MODEL.DECODER.hidden_size,
          dec_recurrent=cfg.MODEL.DECODER.recurrent,
          dec_activation=cfg.MODEL.DECODER.activation,
          dec_pre_norm=cfg.MODEL.DECODER.pre_norm,
          layout=cfg.MODEL.layout,
          embed_initializer=embed_initializer,
          weight_initializer=weight_initializer,
          bias_initializer=bias_initializer,
          dtype=dtype,
      )
  
imports: import os
  from typing import Tuple, List
  import mxnet
  from mxnet import use_np
  from mxnet.gluon import nn
  from .base import BACKBONE_REGISTRY
  from .transformer import TransformerModel
  from ..base import get_model_zoo_home_dir, get_repo_model_zoo_url, get_model_zoo_checksum_dir
  from ..utils.misc import download, load_checksum_stats
  from ..utils.config import CfgNode
  from ..utils.registry import Registry
  from ..data.tokenizers import HuggingFaceByteBPETokenizer
label_desc: Use image node_id 7 for calling the BartModel obj's underlying member method code with example usage: obj.from_cfg(cls, cfg, dtype, extract_feature, use_pooler, classifier_activation) and returns: cls