class_docstr: Hold all parsed data to serve for user requests.
class_docstr_tok: ["Hold","all","parsed","data","to","serve","for","user","requests","."]
code: def get_userdefined_perspective(self, time_unit):
      if not self.overview_parser:
          return
      data = OrderedDict()
      if self.overview_parser.has_device:
          data["column_name"] = [
              "name",
              "calls",
              "cpu_total_time",
              "cpu_avg_time",
              "cpu_max_time",
              "cpu_min_time",
              "cpu_ratio",
              "gpu_total_time",
              "gpu_avg_time",
              "gpu_max_time",
              "gpu_min_time",
              "gpu_ratio",
          ]
          data["has_gpu"] = True
      else:
          data["column_name"] = [
              "name",
              "calls",
              "cpu_total_time",
              "cpu_avg_time",
              "cpu_max_time",
              "cpu_min_time",
              "cpu_ratio",
          ]
          data["has_gpu"] = False
      data["events"] = []
  
      total_cpu_time = 0
      total_gpu_time = 0
      for name, event in self.userdefined_items.items():
          total_cpu_time += event.cpu_time
          total_gpu_time += event.general_gpu_time
      for name, event in self.userdefined_items.items():
          if self.overview_parser.has_device:
              data["events"].append(
                  {
                      "name": name,
                      "calls": event.call,
                      "cpu_total_time": format_time(
                          event.cpu_time, time_unit
                      ),
                      "cpu_avg_time": format_time(
                          event.avg_cpu_time, time_unit
                      ),
                      "cpu_max_time": format_time(
                          event.max_cpu_time, time_unit
                      ),
                      "cpu_min_time": format_time(
                          event.min_cpu_time, time_unit
                      ),
                      "cpu_ratio": format_ratio(
                          event.cpu_time / total_cpu_time
                          if total_cpu_time != 0
                          else 0.0
                      ),
                      "gpu_total_time": format_time(
                          event.general_gpu_time, time_unit
                      ),
                      "gpu_avg_time": format_time(
                          event.avg_general_gpu_time, time_unit
                      ),
                      "gpu_max_time": format_time(
                          event.max_general_gpu_time, time_unit
                      ),
                      "gpu_min_time": format_time(
                          event.min_general_gpu_time, time_unit
                      ),
                      "gpu_ratio": format_ratio(
                          event.general_gpu_time / total_gpu_time
                          if total_gpu_time != 0
                          else 0.0
                      ),
                  }
              )
          else:
              data["events"].append(
                  {
                      "name": name,
                      "calls": event.call,
                      "cpu_total_time": format_time(
                          event.cpu_time, time_unit
                      ),
                      "cpu_avg_time": format_time(
                          event.avg_cpu_time, time_unit
                      ),
                      "cpu_max_time": format_time(
                          event.max_cpu_time, time_unit
                      ),
                      "cpu_min_time": format_time(
                          event.min_cpu_time, time_unit
                      ),
                      "cpu_ratio": format_ratio(
                          event.cpu_time / total_cpu_time
                          if total_cpu_time != 0
                          else 0.0
                      ),
                  }
              )
      return data
  
imports: from collections import defaultdict
  from collections import OrderedDict
  from .parser.distributed_parser import DistributedParser
  from .parser.kernel_parser import KernelParser
  from .parser.memory_parser import MemoryParser
  from .parser.operator_parser import OperatorParser
  from .parser.overview_parser import CPUType
  from .parser.overview_parser import GPUType
  from .parser.overview_parser import OverviewParser
  from .parser.trace_parser import TraceParser
  from .parser.utils import format_float
  from .parser.utils import format_memory
  from .parser.utils import format_ratio
  from .parser.utils import format_time
  from .parser.utils import traverse_tree
label_desc: Use image node_id 8 for calling the ProfilerData obj's underlying member method code with example usage: obj.get_userdefined_perspective(time_unit) and returns: data