code: def fill_quant_pb_layer(
      tensor_names, state_dict, layer, mapping_dict
  ):
      for proto_name, ckpt_rule in mapping_dict.items():
          target_tensor = apply_rule(
              proto_name, ckpt_rule, tensor_names, state_dict
          )
          if proto_name.endswith("_clip_max"):
              if (
                  proto_name
                  == "encode_output_project_kernel_kv_clip_max"
              ):
                  exec("layer.%s[:]=target_tensor" % proto_name)
              else:
                  target_value = float(target_tensor[0])
                  exec("layer.%s=target_value" % proto_name)
          elif "kernel" in proto_name:
              exec(
                  "layer.%s=bytes(target_tensor.flatten().tolist())"
                  % proto_name
              )
          else:
              exec(
                  "layer.%s[:]=target_tensor.flatten().tolist()"
                  % proto_name
              )
  
file_path: lightseq/examples/inference/python/export/fairseq/ls_torch_fs_quant_transformer_export.py
imports: from collections import OrderedDict
  import torch
  from export.proto.quant_transformer_pb2 import QuantTransformer
  from lightseq.training.ops.pytorch.export import export_ls_config, apply_rule
  from lightseq.training.ops.pytorch.export_quant import gather_quant_token_embedding, quantize
  from lightseq.training.ops.pytorch.util import get_pos_embedding
  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: fill_quant_pb_layer(tensor_names, state_dict, layer, mapping_dict) without return types