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_event_type_perspective(self, device_type, time_unit):
      if not self.overview_parser:
          return
      data = OrderedDict()
      data["order"] = []
      if device_type == "cpu":
          for event_type in CPUType:
              event_type_data = {}
              event_type_data["calling_times"] = {}
              event_type_data["calling_times"]["key"] = []
              event_type_data["calling_times"]["value"] = []
              event_type_data["durations"] = {}
              event_type_data["durations"]["key"] = []
              event_type_data["durations"]["value"] = []
              event_type_data["ratios"] = {}
              event_type_data["ratios"]["key"] = []
              event_type_data["ratios"]["value"] = []
              for stage_name in [
                  "Dataloader",
                  "Forward",
                  "Backward",
                  "Optimization",
                  "Other",
              ]:
                  if stage_name in self.merged_events_per_stage:
                      if (
                          event_type
                          in self.merged_events_per_stage[stage_name][
                              "CPU"
                          ]["ALL"]
                      ):
                          event_type_data["calling_times"][
                              "key"
                          ].append(stage_name)
                          event_type_data["durations"]["key"].append(
                              stage_name
                          )
                          event_type_data["ratios"]["key"].append(
                              stage_name
                          )
                          event_type_data["calling_times"][
                              "value"
                          ].append(
                              self.merged_events_per_stage[stage_name][
                                  "CPU"
                              ]["ALL"][event_type]["calls"]
                          )
                          event_type_data["durations"]["value"].append(
                              format_time(
                                  self.merged_events_per_stage[
                                      stage_name
                                  ]["CPU"]["ALL"][event_type][
                                      "total_time"
                                  ],
                                  time_unit,
                              )
                          )
                          event_type_data["ratios"]["value"].append(
                              format_ratio(
                                  self.merged_events_per_stage[
                                      stage_name
                                  ]["CPU"]["ALL"][event_type][
                                      "total_time"
                                  ]
                                  / self.merged_events_per_stage[
                                      "ProfileStep"
                                  ]["CPU"]["ALL"][event_type][
                                      "total_time"
                                  ]
                              )
                          )
              if event_type_data["calling_times"]["key"]:
                  data[event_type] = event_type_data
                  data["order"].append(event_type)
      else:
          for event_type in GPUType:
              event_type_data = {}
              event_type_data["calling_times"] = {}
              event_type_data["calling_times"]["key"] = []
              event_type_data["calling_times"]["value"] = []
              event_type_data["durations"] = {}
              event_type_data["durations"]["key"] = []
              event_type_data["durations"]["value"] = []
              event_type_data["ratios"] = {}
              event_type_data["ratios"]["key"] = []
              event_type_data["ratios"]["value"] = []
              for stage_name in [
                  "Dataloader",
                  "Forward",
                  "Backward",
                  "Optimization",
                  "Other",
              ]:
                  if stage_name in self.merged_events_per_stage:
                      if (
                          event_type
                          in self.merged_events_per_stage[stage_name][
                              "GPU"
                          ]["ALL"]
                      ):
                          event_type_data["calling_times"][
                              "key"
                          ].append(stage_name)
                          event_type_data["durations"]["key"].append(
                              stage_name
                          )
                          event_type_data["ratios"]["key"].append(
                              stage_name
                          )
                          event_type_data["calling_times"][
                              "value"
                          ].append(
                              self.merged_events_per_stage[stage_name][
                                  "GPU"
                              ]["ALL"][event_type]["calls"]
                          )
                          event_type_data["durations"]["value"].append(
                              format_time(
                                  self.merged_events_per_stage[
                                      stage_name
                                  ]["GPU"]["ALL"][event_type][
                                      "total_time"
                                  ],
                                  time_unit,
                              )
                          )
                          event_type_data["ratios"]["value"].append(
                              format_ratio(
                                  self.merged_events_per_stage[
                                      stage_name
                                  ]["GPU"]["ALL"][event_type][
                                      "total_time"
                                  ]
                                  / self.merged_events_per_stage[
                                      "ProfileStep"
                                  ]["GPU"]["ALL"][event_type][
                                      "total_time"
                                  ]
                              )
                          )
              if event_type_data["calling_times"]["key"]:
                  data[event_type] = event_type_data
                  data["order"].append(event_type)
      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 6 for calling the ProfilerData obj's underlying member method code with example usage: obj.get_event_type_perspective(device_type, time_unit) and returns: data