code: def save_profile_data(csv_data, events, use_cuda):
      sum_self_cpu_time_total = sum(
          [event.self_cpu_time_total for event in events]
      )
      sum_cpu_time_total = sum(
          [event.self_cpu_time_total for event in events]
      )
      sum_self_cuda_time_total = (
          sum([event.self_cuda_time_total for event in events])
          if use_cuda
          else 0
      )
  
      for e in events[:5]:  # Save top 5 most time consuming operations:
          csv_data["NAME"].append(e.key)
          csv_data["SELF CPU %"].append(
              round(
                  e.self_cpu_time_total
                  * 100.0
                  / sum_self_cpu_time_total,
                  3,
              )
          )
          csv_data["SELF CPU"].append(
              format_prof_time(e.self_cpu_time_total)
          )
          csv_data["CPU TOTAL %"].append(
              round(e.cpu_time_total * 100.0 / sum_cpu_time_total, 3)
          )
          csv_data["CPU TOTAL"].append(
              format_prof_time(e.cpu_time_total)
          )
          csv_data["CPU TIME AVG"].append(
              format_prof_time(e.cpu_time_total)
          )
          if use_cuda:
              csv_data["SELF CUDA %"].append(
                  e.self_cuda_time_total
                  * 100.0
                  / sum_self_cuda_time_total
              )
              csv_data["SELF CUDA"].append(
                  format_prof_time(e.self_cuda_time_total)
              )
              csv_data["CUDA TOTAL"].append(
                  format_prof_time(e.cpu_time_total)
              )
              csv_data["CUDA TIME AVG"].append(
                  format_prof_time(e.cpu_time_total)
              )
          csv_data["# OF CALLS"].append(e.count)
  
imports: import os
  import pathlib
  import time
  from contextlib import ContextDecorator, contextmanager
  from dataclasses import dataclass
  from typing import Any, List, Tuple, Union
  import torch
  from torch.autograd.profiler import EventList
  from torch.profiler import ProfilerActivity, profile
  from torch_geometric.profile.utils import byte_to_megabyte, get_gpu_memory_from_ipex, get_gpu_memory_from_nvidia_smi
label_desc: Use image node_id 10 for calling a global function with example usage: save_profile_data(csv_data, events, use_cuda) without return types