code: def export_fs_weights(transformer, state_dict, args):
      enc_norm_w = (
          state_dict["encoder.layer_norm.weight"].flatten().tolist()
      )
      enc_norm_b = (
          state_dict["encoder.layer_norm.bias"].flatten().tolist()
      )
      dec_norm_w = (
          state_dict["decoder.layer_norm.weight"].flatten().tolist()
      )
      dec_norm_b = (
          state_dict["decoder.layer_norm.bias"].flatten().tolist()
      )
      emb_size = state_dict["decoder.embed_tokens.para"].size(0) - 1
      assert emb_size % args.decoder_embed_dim == 0
      dec_shared_b = (
          torch.zeros(emb_size // args.decoder_embed_dim)
          .flatten()
          .tolist()
      )
      transformer.src_embedding.norm_scale[:] = enc_norm_w
      transformer.src_embedding.norm_bias[:] = enc_norm_b
      transformer.trg_embedding.norm_scale[:] = dec_norm_w
      transformer.trg_embedding.norm_bias[:] = dec_norm_b
      transformer.trg_embedding.shared_bias[:] = dec_shared_b
  
file_path: lightseq/examples/inference/python/export/fairseq/ls_fs_transformer_ptq_export.py
imports: import torch
  from export.proto.quant_transformer_pb2 import QuantTransformer
  from lightseq.training import export_ls_config, export_ls_embedding_ptq, export_ls_encoder_ptq, export_ls_decoder_ptq
  import lightseq.inference
  from export.util import parse_args, save_model
label_desc: Use image node_id 2 for calling a global function with example usage: export_fs_weights(transformer, state_dict, args) without return types