code: def fill_quant_hdf5_layer(
      tensor_names,
      state_dict,
      hdf5_file,
      hdf5_dataset_prefix,
      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 proto_name.endswith("_clip_max"):
              hdf5_file.create_dataset(
                  hdf5_dataset_prefix + proto_name,
                  data=float(target_tensor[0]),
              )
          elif "kernel" in proto_name:
              weight_clip_max = 1
              target_tensor = quantize(
                  target_tensor, global_quant_range, weight_clip_max
              )
              hdf5_file.create_dataset(
                  hdf5_dataset_prefix + proto_name,
                  data=target_tensor,
                  dtype="uint8",
              )
              if proto_name == "encode_output_project_kernel_kv":
                  assert nlayer is not None
                  clip_maxs = np.array([weight_clip_max] * int(nlayer))
                  hdf5_file.create_dataset(
                      hdf5_dataset_prefix + proto_name + "_clip_max",
                      data=clip_maxs,
                  )
              else:
                  hdf5_file.create_dataset(
                      hdf5_dataset_prefix + proto_name + "_clip_max",
                      data=float(weight_clip_max),
                  )
          else:
              hdf5_file.create_dataset(
                  hdf5_dataset_prefix + proto_name,
                  data=target_tensor,
              )
  
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 6 for calling a global function with example usage: fill_quant_hdf5_layer(tensor_names, state_dict, hdf5_file, hdf5_dataset_prefix, mapping_dict, nlayer) without return types