code: def fill_layer(tensor_names, stete_dict, layer, mapping_dict):
      for proto_name, ckpt_rule in mapping_dict.items():
          expression = [
              ele
              for ele in ckpt_rule.split("&&")
              if ele.startswith("expression_")
          ]
  
          ckpt_rule = [
              ele
              for ele in ckpt_rule.split("&&")
              if not ele.startswith("expression_")
          ]
  
          assert (len(ckpt_rule) > 0 and len(expression) < 2) or (
              len(ckpt_rule) == 0 and len(expression) > 0
          )
  
          if len(expression) < 2:
              expression = (
                  "" if not expression else expression[0].split("_")[1]
              )
          else:
              expression = [exp.split("_")[1] for exp in expression]
  
          target_tn = []
          for cr in ckpt_rule:
              tmp = []
              for tn in tensor_names:
                  if check_rule(tn, cr):
                      tmp.append(tn)
              assert len(tmp) <= 1
              target_tn.extend(tmp)
          if not target_tn and proto_name == "gate_kernel":
              continue
          target_tensor = [stete_dict[name] for name in target_tn]
          tt = {}
          if target_tensor:
              exec(
                  "tt['save'] = [ele%s for ele in target_tensor]"
                  % expression
              )
          else:
              if not isinstance(expression, list):
                  expression = [expression]
              exec("tt['save'] = [%s]" % ",".join(expression))
  
          target_tensor = np.concatenate(tt["save"], axis=-1)
          print(
              "%s -> %s, shape: %s, convert finished."
              % (
                  target_tn if target_tn else "created",
                  proto_name,
                  target_tensor.shape,
              )
          )
          exec(
              "layer.%s[:]=target_tensor.flatten().tolist()"
              % proto_name
          )
  
file_path: lightseq/examples/inference/python/export/fairseq/native_fs_moe_transformer_export.py
imports: import os
  import torch
  import argparse
  import numpy
  from collections import OrderedDict
  import lightseq.inference
  from proto.moe_pb2 import Moe
  from lightseq.training.ops.pytorch.export import gather_token_embedding, export_ls_config
  from lightseq.training.ops.pytorch.util import get_pos_embedding
label_desc: Use image node_id 3 for calling a global function with example usage: fill_layer(tensor_names, stete_dict, layer, mapping_dict) without return types