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_operator_pie(self, topk, time_unit="ms"):
      if not self.operator_parser:
          return
      data = OrderedDict()
      data["column_name"] = [
          "name",
          "calls",
          "total_time",
          "avg_time",
          "max_time",
          "min_time",
          "ratio",
      ]
      data["cpu"] = []
      if self.has_gpu:
          data["gpu"] = []
          gpu_sorted_items = sorted(
              self.operator_items.items(),
              key=lambda x: x[1].general_gpu_time,
              reverse=True,
          )
  
      cpu_sorted_items = sorted(
          self.operator_items.items(),
          key=lambda x: x[1].cpu_time,
          reverse=True,
      )
  
      if topk <= 0:
          cpu_items = cpu_sorted_items
          if self.has_gpu:
              gpu_items = gpu_sorted_items
      else:
          cpu_items = cpu_sorted_items[:topk]
          if self.has_gpu:
              gpu_items = gpu_sorted_items[:topk]
      total_cpu_time = 0.0
      total_gpu_time = 0.0
      for op_name, item in cpu_items:
          total_cpu_time += item.cpu_time
      if self.has_gpu:
          for op_name, item in gpu_items:
              total_gpu_time += item.general_gpu_time
  
      for op_name, item in cpu_items:
          cpu_stage_data = OrderedDict()
          cpu_stage_data["name"] = op_name
          cpu_stage_data["calls"] = item.call
          cpu_stage_data["total_time"] = format_time(
              item.cpu_time, time_unit
          )
          cpu_stage_data["avg_time"] = format_time(
              item.avg_cpu_time, time_unit
          )
          cpu_stage_data["max_time"] = format_time(
              item.max_cpu_time, time_unit
          )
          cpu_stage_data["min_time"] = format_time(
              item.min_cpu_time, time_unit
          )
          cpu_stage_data["ratio"] = format_ratio(
              item.cpu_time / total_cpu_time
          )
          data["cpu"].append(cpu_stage_data)
      if self.has_gpu:
          for op_name, item in gpu_items:
              gpu_stage_data = OrderedDict()
              gpu_stage_data["name"] = op_name
              gpu_stage_data["calls"] = item.call
              gpu_stage_data["total_time"] = format_time(
                  item.general_gpu_time, time_unit
              )
              gpu_stage_data["avg_time"] = format_time(
                  item.avg_general_gpu_time, time_unit
              )
              gpu_stage_data["max_time"] = format_time(
                  item.max_general_gpu_time, time_unit
              )
              gpu_stage_data["min_time"] = format_time(
                  item.min_general_gpu_time, time_unit
              )
              gpu_stage_data["ratio"] = format_ratio(
                  item.general_gpu_time / total_gpu_time
              )
              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 9 for calling the ProfilerData obj's underlying member method code with example usage: obj.get_operator_pie(topk, time_unit) and returns: data