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
  
imports: import time
  import torch
  from torch import nn
  from transformers import GPT2Tokenizer, GPT2LMHeadModel, GPT2Config
  import lightseq.inference
  from lightseq.training.ops.pytorch.quantization import qat_mode, QuantLinear, TensorQuantizer, weight_quant_config, emb_quant_config
  from lightseq.training.ops.pytorch.torch_transformer_layers import TransformerDecoderLayer
  from export.util import parse_args
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