code: def test_transformer_cfg(cfg_key):
      cfg = TransformerModel.get_cfg(cfg_key)
      cfg.defrost()
      cfg.MODEL.src_vocab_size = 32
      cfg.MODEL.tgt_vocab_size = 32
      cfg.freeze()
      model = TransformerModel.from_cfg(cfg)
      model.initialize()
      model.hybridize()
      cfg.defrost()
      cfg.MODEL.layout = "TN"
      cfg.freeze()
      model_tn = TransformerModel.from_cfg(cfg)
      model_tn.share_parameters(model.collect_params())
      model_tn.hybridize()
      mx.npx.waitall()
  
file_path: gluon-nlp/tests/test_models_transformer.py
imports: import numpy
  import mxnet
  import pytest
  from numpy.testing import assert_allclose
  from gluonnlp.models.transformer import TransformerEncoder, TransformerDecoder, TransformerModel, TransformerInference, transformer_cfg_reg
  from gluonnlp.attention_cell import gen_mem_attn_mask, gen_self_attn_mask
  from gluonnlp.utils.testing import verify_nmt_model, verify_nmt_inference
  from gluonnlp.utils.testing import verify_backbone_fp16
  from gluonnlp.utils.parameter import count_parameters, deduplicate_param_dict
label_desc: Use image node_id 4 for calling a global function with example usage: test_transformer_cfg(cfg_key) without return types