code: def fill_quant_pb_layer(
      tensor_names,
      state_dict,
      layer,
      mapping_dict,
      nlayer=None,
  ):
      for proto_name, ckpt_rule in mapping_dict.items():
          target_tensor = apply_rule(
              proto_name, ckpt_rule, tensor_names, state_dict
          )
          if "clip_max" in proto_name:
              assert len(target_tensor) == 1
              exec("layer.%s=target_tensor[0]" % proto_name)
          elif "kernel" in proto_name:
              weight_clip_max = 1
              target_tensor = quantize(
                  target_tensor, global_quant_range, weight_clip_max
              )
              exec(
                  "layer.%s=bytes(target_tensor.flatten().tolist())"
                  % proto_name
              )
              if proto_name == "encode_output_project_kernel_kv":
                  assert nlayer is not None
                  clip_maxs = [weight_clip_max] * int(nlayer)
                  exec("layer.%s_clip_max[:]=clip_maxs" % proto_name)
              else:
                  exec("layer.%s_clip_max=weight_clip_max" % proto_name)
              print("%s_clip_max convert finished!" % proto_name)
          else:
              exec(
                  "layer.%s[:]=target_tensor.flatten().tolist()"
                  % proto_name
              )
  
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 5 for calling a global function with example usage: fill_quant_pb_layer(tensor_names, state_dict, layer, mapping_dict, nlayer) without return types