code: def convert_params(args, converted, hf_model, gluon_model):
      print("converting parameters...")
      # prepare models and parameters
      gluon_model.initialize()
      hf_params = hf_model.state_dict()
      gluon_params = gluon_model.collect_params()
      # TODO(yongyi-wu): add sanity check, eg. param #, layer #, ffn activation, etc.
      num_layers = gluon_model.num_layers
  
      def convert(hf_param, gluon_param):
          gluon_params[gluon_param].set_data(
              hf_params[hf_param].cpu().numpy()
          )
  
      # convert parameters
      for idx, (hf_key, gluon_key) in enumerate(PARAM_MAP):
          if idx == 0:
              convert(hf_key, gluon_key)
          elif idx == 1:
              for i in ["encoder", "decoder"]:
                  convert(hf_key.format(i), gluon_key.format(i))
          elif idx in [2, 3, 4, 5]:
              for stack in ["encoder", "decoder"]:
                  for layer in range(num_layers):
                      if idx == 2:
                          if stack == "encoder":
                              L = [
                                  "self_attn_layer_norm",
                                  "ffn.layer_norm",
                              ]
                          else:
                              L = [
                                  "self_attn_layer_norm",
                                  "cross_attn_layer_norm",
                                  "ffn.layer_norm",
                              ]
                          for i, j in enumerate(L):
                              convert(
                                  hf_key.format(stack, layer, i),
                                  gluon_key.format(stack, layer, j),
                              )
                      elif idx == 3:
                          for i in ["q", "k", "v"]:
                              convert(
                                  hf_key.format(
                                      stack, layer, "0.Self", i
                                  ),
                                  gluon_key.format(
                                      stack, layer, "self", i
                                  ),
                              )
                              if stack == "decoder":
                                  convert(
                                      hf_key.format(
                                          stack, layer, "1.EncDec", i
                                      ),
                                      gluon_key.format(
                                          stack, layer, "cross", i
                                      ),
                                  )
                      elif idx == 4:
                          convert(
                              hf_key.format(
                                  stack, layer, "0.SelfAttention.o"
                              ),
                              gluon_key.format(
                                  stack, layer, "self_attn_proj"
                              ),
                          )
                          if stack == "decoder":
                              convert(
                                  hf_key.format(
                                      stack,
                                      layer,
                                      "1.EncDecAttention.o",
                                  ),
                                  gluon_key.format(
                                      stack, layer, "cross_attn_proj"
                                  ),
                              )
                      elif idx == 5:
                          if gluon_model.activation == "relu":
                              denses = [
                                  ("wi", "ffn_1"),
                                  ("wo", "ffn_2"),
                              ]
                          elif gluon_model.activation == "gated-gelu":
                              denses = [
                                  ("wi_0", "gated_ffn_1"),
                                  ("wi_1", "ffn_1"),
                                  ("wo", "ffn_2"),
                              ]
                          else:
                              raise ValueError
                          i = 1 if stack == "encoder" else 2
                          for j1, j2 in denses:
                              convert(
                                  hf_key.format(stack, layer, i, j1),
                                  gluon_key.format(stack, layer, j2),
                              )
          elif idx == 6:
              for stack in ["encoder", "decoder"]:
                  convert(hf_key.format(stack), gluon_key.format(stack))
      # save parameters
      param_path = os.path.join(args.dest_dir, "model.params")
      gluon_model.save_parameters(param_path)
      converted["params"] = param_path
      return gluon_model
  
imports: import argparse
  import logging
  import json
  import os
  import shutil
  import tempfile
  import torch
  import mxnet
  from mxnet import np, npx
  from gluonnlp.attention_cell import gen_self_attn_mask, gen_mem_attn_mask
  from gluonnlp.data.tokenizers import SentencepieceTokenizer
  from gluonnlp.models.t5 import T5Model
  from gluonnlp.utils.misc import download, logging_config, sha1sum, naming_convention
  from transformers import T5Model
label_desc: Use image node_id 4 for calling a global function with example usage: convert_params(args, converted, hf_model, gluon_model) and returns: gluon_model