code: def update_csv_report(csv_results_file, benchmark_result_list, ngpus):
      """
      Update (or create if DNE) csv_results_file as a CSV file containing the
      benchmark results.  Rows are the runtimes, columns are number of GPUs.
      """
      new_times = {}
      new_names = set()
      names_from_csv = set()
  
      ngpus_key = f"ngpus_{ngpus}"
      all_fields = set(["name", ngpus_key])
  
      for r in benchmark_result_list:
          name = r.name
          new_names.add(name)
          new_times[name] = f"{r.runtime:.6}"
  
      rows = []
  
      # Read in rows from an existing CSV, then add the new time for the current
      # run with a (possibly new) number of GPUs.
      # This also accumulates all the unique field names.
      if path.exists(csv_results_file):
          with open(csv_results_file) as csv_file:
              reader = csv.DictReader(csv_file)
              for row in reader:
                  algo_name_from_csv = row["name"]
                  names_from_csv.add(algo_name_from_csv)
                  if algo_name_from_csv in new_times:
                      row[ngpus_key] = new_times[algo_name_from_csv]
                  # Ensure all fields in each row are added
                  [all_fields.add(f) for f in row.keys()]
                  rows.append(row)
  
      # Add any new algos that were not present in the existing CSV. If there was
      # no existing CSV, then this is all the algos ran in this run.
      for name in new_names - names_from_csv:
          rows.append(
              {
                  "name": name,
                  ngpus_key: new_times[name],
              }
          )
  
      with open(csv_results_file, "w") as csv_file:
          field_names = sorted(all_fields)
          writer = csv.DictWriter(csv_file, fieldnames=field_names)
          writer.writeheader()
          for row in rows:
              writer.writerow(row)
  
imports: from os import path
  import csv
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: update_csv_report(csv_results_file, benchmark_result_list, ngpus) without return types