code: def benchmark_training(model, inputs: Dict, num_training_steps: int):
      progress_bar = tqdm(range(num_training_steps))
  
      model.train()
      # warmup
      for _ in range(5):
          outputs = model(**inputs)
          loss = outputs.logits.sum()
          loss.backward()
  
      start_event = torch.cuda.Event(enable_timing=True)
      end_event = torch.cuda.Event(enable_timing=True)
  
      torch.cuda.reset_peak_memory_stats(device)
      torch.cuda.empty_cache()
  
      torch.cuda.synchronize()
      start_event.record()
      for _ in range(num_training_steps):
          model.zero_grad()
          outputs = model(**inputs)
          loss = outputs.logits.sum()
          loss.backward()
  
          progress_bar.update(1)
      end_event.record()
      torch.cuda.synchronize()
  
      max_memory = torch.cuda.max_memory_allocated(device)
  
      return (
          start_event.elapsed_time(end_event) * 1.0e-3
      ) / num_training_steps, max_memory
  
file_path: optimum/tests/benchmark/benchmark_bettertransformer_training_minimal.py
imports: import argparse
  import random
  from typing import Dict
  import numpy
  import torch
  from tqdm.auto import tqdm
  from transformers import AutoModelForCausalLM
  from optimum.bettertransformer import BetterTransformer
label_desc: Use image node_id 3 for calling a global function with example usage: benchmark_training(model, inputs, num_training_steps) and returns: unknown,  max_memory