class_docstr: Hold all parsed data to serve for user requests.
class_docstr_tok: ["Hold","all","parsed","data","to","serve","for","user","requests","."]
docstr: Get total cpu and gpu statistics for model perspective of each profiler step.
docstr_tok: ["Get","total","cpu","and","gpu","statistics","for","model","perspective","of","each","profiler","step","."]
code: def get_model_perspective(self, time_unit):
      """
      Get total cpu and gpu statistics for model perspective of each profiler step.
      """
      if not self.overview_parser:
          return
      data = OrderedDict()
      data["column_name"] = [
          "name",
          "calls",
          "total_time",
          "avg_time",
          "max_time",
          "min_time",
          "ratio",
      ]
      data["cpu"] = []
      if self.overview_parser.has_device:
          data["gpu"] = []
      total_cpu_time = self.model_perspective_items[
          "ProfileStep"
      ].cpu_time
      total_gpu_time = self.model_perspective_items[
          "ProfileStep"
      ].gpu_time
      for stage_name in [
          "ProfileStep",
          "Dataloader",
          "Forward",
          "Backward",
          "Optimization",
          "Other",
      ]:
          if stage_name in self.model_perspective_items:
              cpu_stage_data = OrderedDict()
              cpu_stage_data["name"] = stage_name
              cpu_stage_data["calls"] = self.model_perspective_items[
                  stage_name
              ].call
              cpu_stage_data["total_time"] = format_time(
                  self.model_perspective_items[stage_name].cpu_time,
                  time_unit,
              )
              cpu_stage_data["avg_time"] = format_time(
                  self.model_perspective_items[stage_name].avg_cpu_time,
                  time_unit,
              )
              cpu_stage_data["max_time"] = format_time(
                  self.model_perspective_items[stage_name].max_cpu_time,
                  time_unit,
              )
              cpu_stage_data["min_time"] = format_time(
                  self.model_perspective_items[stage_name].min_cpu_time,
                  time_unit,
                  inf_subs=0,
              )
              cpu_stage_data["ratio"] = format_ratio(
                  self.model_perspective_items[stage_name].cpu_time
                  / total_cpu_time
              )
              if self.overview_parser.has_device:
                  gpu_stage_data = OrderedDict()
                  gpu_stage_data["name"] = stage_name
                  gpu_stage_data[
                      "calls"
                  ] = self.model_perspective_items[stage_name].call
                  gpu_stage_data["total_time"] = format_time(
                      self.model_perspective_items[stage_name].gpu_time,
                      time_unit,
                  )
                  gpu_stage_data["avg_time"] = format_time(
                      self.model_perspective_items[
                          stage_name
                      ].avg_gpu_time,
                      time_unit,
                  )
                  gpu_stage_data["max_time"] = format_time(
                      self.model_perspective_items[
                          stage_name
                      ].max_gpu_time,
                      time_unit,
                  )
                  gpu_stage_data["min_time"] = format_time(
                      self.model_perspective_items[
                          stage_name
                      ].min_gpu_time,
                      time_unit,
                      inf_subs=0,
                  )
                  gpu_stage_data["ratio"] = format_ratio(
                      self.model_perspective_items[stage_name].gpu_time
                      / total_gpu_time
                  )
              data["cpu"].append(cpu_stage_data)
              if self.overview_parser.has_device:
                  data["gpu"].append(gpu_stage_data)
      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 4 for calling the ProfilerData obj's underlying member method code with example usage: obj.get_model_perspective(time_unit) and returns: data