code: def export_ls_quant_embedding(
      file,
      state_dict,
      max_length,
      emb_dim,
      is_encoder,
      save_pb=True,
  ):
      var_name_list = list(state_dict.keys())
      emb, clip_max, target_tn = gather_quant_token_embedding(
          var_name_list, state_dict, "embed_tokens", ptq_mode=False
      )
      emb_size = emb.flatten().shape[0] - 1
      assert emb_size % emb_dim == 0
      emb = emb.flatten()[:-1].reshape(emb_size // emb_dim, emb_dim)
  
      if is_encoder:
          emb_list = emb.flatten().tolist()
          file.src_embedding.token_embedding = bytes(emb_list)
          file.src_embedding.emb_clip_max = clip_max
      else:
          emb_list = emb.transpose().flatten().tolist()
          file.trg_embedding.token_embedding = bytes(emb_list)
          file.trg_embedding.emb_clip_max = clip_max
      print(
          "%s -> %s_embedding.token_embedding, convert finished!"
          % (target_tn, "src" if is_encoder else "trg")
      )
      print("%s emb_clip_max convert finished!" % target_tn)
  
      pos_emb = get_pos_embedding(max_length, emb.shape[-1])
      pos_emb_list = pos_emb.flatten().tolist()
      if is_encoder:
          file.src_embedding.position_embedding[:] = pos_emb_list
      else:
          file.trg_embedding.position_embedding[:] = pos_emb_list
      target_tn = [
          tn.replace("embeddings", "pos_embeddings") for tn in target_tn
      ]
      print(
          "%s -> %s_embedding.position_embedding, convert finished!"
          % (target_tn, "src" if is_encoder else "trg")
      )
  
imports: from collections import OrderedDict
  import numpy
  from lightseq.training.ops.pytorch.util import get_pos_embedding
  from lightseq.training import LSTransformerEncoderLayer, LSTransformerDecoderLayer
  from lightseq.training.ops.pytorch.export import apply_rule
label_desc: Use image node_id 12 for calling a global function with example usage: export_ls_quant_embedding(file, state_dict, max_length, emb_dim, is_encoder, save_pb) without return types