code: def main():
      parser = argparse.ArgumentParser()
      parser.add_argument("--user_input", action="store_true")
      args = parser.parse_args()
  
      print("initializing xglm tokenizer...")
  
      ls_tokenizer = AutoTokenizer.from_pretrained(
          "facebook/incoder-1B"
      )
      # lightseq use len(tokenizer) as pad_token in default
      ls_tokenizer.add_special_tokens({"pad_token": "[PAD]"})
  
      hf_tokenizer = AutoTokenizer.from_pretrained(
          "facebook/incoder-1B"
      )
  
      print("creating lightseq model...")
      # XGLM shares the same model architecture as GPT
      ls_model = lsi.Gpt(
          "lightseq_incoder_base.hdf5", max_batch_size=16
      )
  
      print("creating huggingface model...")
      hf_model = AutoModelForCausalLM.from_pretrained(
          "facebook/incoder-1B"
      )
      hf_model.to("cuda:0")
  
      # lightseq xglm perplexity supports batch infer with different lengths,
      # but sampling doesn't support
      sentences = ["def quick_sort(nums):"]
  
      print("====================START warmup====================")
      warmup(ls_tokenizer, hf_tokenizer, ls_model, hf_model, sentences)
      print("====================END warmup====================")
  
      while True:
          if args.user_input:
              sentences = [input("input the masked sentence:\n")]
  
          print("tokenizing the sentences...")
  
          ls_inputs = ls_tokenizer(sentences, return_tensors="pt")[
              "input_ids"
          ]
          hf_inputs = hf_tokenizer(sentences, return_tensors="pt")[
              "input_ids"
          ]
  
          ls_generate(ls_model, ls_tokenizer, ls_inputs)
          hf_generate(hf_model, hf_tokenizer, hf_inputs)
  
          if not args.user_input:
              break
  
file_path: lightseq/examples/inference/python/test/ls_xglm.py
imports: import time
  import argparse
  import torch
  import numpy
  import lightseq.inference
  from transformers import AutoTokenizer, AutoModelForCausalLM
label_desc: Use image node_id 6 for calling a global function with example usage: main() without return types