code: def _display_results(results):
      nvtx_events = [r for r in results if "runtime" in r]
      nvtx_events.sort(key=lambda r: r["start"])
      max_length = (
          max([len(r["measurement"]) for r in nvtx_events]) + 16
      )
  
      def aggregate(records):
          agg = {}
          for r in records:
              measurement = r["measurement"]
              runtime = int(r["runtime"])
              if measurement in agg:
                  agg[measurement]["runtime"] += runtime
              else:
                  agg[measurement] = {
                      "measurement": measurement,
                      "runtime": runtime,
                      "start": r["start"],
                  }
          agg = list(agg.values())
          agg.sort(key=lambda r: r["start"])
          return agg
  
      def nesting_hierarchy(records):
          ends = []
          for r in records:
              ends = [e for e in ends if r["start"] < e]
              r["nesting_hierarchy"] = len(ends)
              ends.append(r["end"])
          return records
  
      def display(measurement, runtime):
          measurement = measurement.ljust(max_length + 4)
          runtime = round(int(runtime) / 10**9, 4)
          msg = "{measurement} : {runtime:8.4f} s"
          msg = msg.format(measurement=measurement, runtime=runtime)
          print(msg)
  
      while len(nvtx_events):
          record = nvtx_events[0]
          display(record["measurement"], record["runtime"])
  
          #  Filter events belonging to this event
          end = record["end"]
          events_to_print = [
              r for r in nvtx_events[1:] if r["start"] < end
          ]
  
          #  Filter events and compute nesting hierarchy
          reg_events_to_print = [
              r for r in events_to_print if r["category"] != "utils"
          ]
          reg_events_to_print = nesting_hierarchy(reg_events_to_print)
  
          for r in reg_events_to_print:
              measurement = (
                  "    |"
                  + ("==" * r["nesting_hierarchy"])
                  + "> "
                  + r["measurement"]
              )
              display(measurement, r["runtime"])
  
          #  Filter utils events and aggregate them by adding up runtimes
          utils_events_to_print = [
              r for r in events_to_print if r["category"] == "utils"
          ]
          utils_events_to_print = aggregate(utils_events_to_print)
  
          if len(reg_events_to_print) and len(utils_events_to_print):
              print()
          if len(utils_events_to_print):
              print("    Utils summary:")
          for r in utils_events_to_print:
              display("      " + r["measurement"], r["runtime"])
  
          #  Remove events just displayed from the list
          nvtx_events = [r for r in nvtx_events if r["start"] >= end]
          if len(nvtx_events):
              print("\n")
  
file_path: cuml/python/cuml/benchmark/nvtx_benchmark.py
imports: import os
  import shutil
  import sys
  import tempfile
  from subprocess import run
  import json
label_desc: Use image node_id 7 for calling the Profiler obj's underlying member method code with example usage: obj._display_results(results) and returns: agg, records