code: def benchmark(
      model,
      input_ids,
      masks,
      num_batches,
      is_decoder,
      max_token,
      pad_token_id,
  ):
      if is_decoder:
          gen_config = GenerationConfig(
              max_new_tokens=max_token,
              min_new_tokens=max_token,
              use_cache=True,
              pad_token_id=pad_token_id,
              eos_token_id=None,
          )
  
      # warmup
      if is_decoder:
          _ = model.generate(
              input_ids,
              attention_mask=masks,
              generation_config=gen_config,
          )
          torch.cuda.synchronize()
      else:
          _ = model(input_ids, masks)
          torch.cuda.synchronize()
  
      # benchmark
      if is_decoder:
          total_time, max_mem = timing_cuda(
              model,
              num_batches,
              input_ids,
              masks,
              is_decoder,
              gen_config,
          )
      else:
          total_time, max_mem = timing_cuda(
              model, num_batches, input_ids, masks, is_decoder
          )
  
      return total_time, max_mem
  
file_path: optimum/tests/benchmark/benchmark_bettertransformer.py
imports: import argparse
  import numpy
  import pandas
  import torch
  from tqdm import tqdm
  from transformers import AutoModel, AutoModelForCausalLM, AutoModelForSeq2SeqLM, AutoTokenizer, GenerationConfig
  from optimum.bettertransformer import BetterTransformer
  from optimum.exporters import TasksManager
label_desc: Use image node_id 4 for calling a global function with example usage: benchmark(model, input_ids, masks, num_batches, is_decoder, max_token, pad_token_id) and returns: total_time,  max_mem