code: def ls_gpt2(model, inputs, generation_method="topk"):
      torch.cuda.synchronize()
      start_time = time.perf_counter()
      results = None
      if generation_method == "topk" or generation_method == "topp":
          results = model.sample(inputs)
      elif generation_method == "ppl":
          results = model.ppl(inputs)[0]
      torch.cuda.synchronize()
      end_time = time.perf_counter()
      return results, end_time - start_time
  
file_path: lightseq/examples/inference/python/test/ls_gpt2.py
imports: import time
  import argparse
  import torch
  import lightseq.inference
  from transformers import GPT2Tokenizer, GPT2LMHeadModel
label_desc: Use image node_id 1 for calling a global function with example usage: ls_gpt2(model, inputs, generation_method) and returns: results,  unknown