code: def generate_model(args):
      model_path = "lightseq_{}_bench.hdf5".format(
          args.model_name.split("/")[-1]
      )
      if "bart" in args.model_name:
          if not os.path.exists(model_path):
              extract_transformer_weights(
                  model_path.split(".")[0],
                  args.model_name,
                  generation_method=args.sampling_method,
                  beam_size=args.beam_size,
                  topk=args.topk,
                  topp=args.topp,
                  max_step=256
                  if args.output_seq_len < 256
                  else args.output_seq_len,
                  extra_decode_length=args.output_seq_len
                  - args.input_seq_len,
                  only_decoder=False,
                  length_penalty=args.length_penalty,
                  save_proto=False,
              )
  
              return
  
          with h5py.File(model_path, "r+") as f:
              f["model_conf"]["sampling_method"][()] = np.array(
                  [ord(c) for c in args.sampling_method]
              ).astype(np.int8)
              f["model_conf"]["beam_size"][()] = args.beam_size
              f["model_conf"]["topk"][()] = args.topk
              f["model_conf"]["topp"][()] = args.topp
              f["model_conf"]["extra_decode_length"][()] = (
                  args.output_seq_len - args.input_seq_len
              )
              f["model_conf"]["length_penalty"][
                  ()
              ] = args.length_penalty
  
      elif "gpt" in args.model_name or "clm" in args.model_name:
          if args.enable_quant:
              model_path = "lightseq_quant_gpt2_bench.hdf5".format(
                  args.model_name.split("/")[-1]
              )
  
              extract_quant_gpt_weights(
                  model_path,
                  args.model_name,
                  generation_method=args.sampling_method,
                  topk=args.topk,
                  topp=args.topp,
                  eos_id=50256,
                  pad_id=50257,
                  max_step=args.input_seq_len + args.output_seq_len,
              )
          else:
              extract_gpt_weights(
                  model_path.split(".")[0],
                  args.model_name,
                  generation_method=args.sampling_method,
                  topk=args.topk,
                  topp=args.topp,
                  eos_id=50256,
                  pad_id=50257,
                  max_step=args.input_seq_len + args.output_seq_len,
              )
      else:
          raise ValueError(
              "can't infer model type from {}, generate model failed".format(
                  args.model_name
              )
          )
  
      return os.path.realpath(model_path)
  
file_path: lightseq/examples/inference/python/generate_model.py
imports: import argparse
  import subprocess
  import os
  import re
  import h5py
  import numpy
  from export.huggingface.hf_bart_export import extract_transformer_weights
  from export.huggingface.hf_gpt2_export import extract_gpt_weights
  from export.huggingface.ls_hf_quant_gpt2_export import extract_gpt_weights
label_desc: Use image node_id 2 for calling a global function with example usage: generate_model(args) and returns: os