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_expand(  # noqa: C901
      self, topk, device_type, time_unit
  ):
      if not self.operator_parser:
          return
      data = OrderedDict()
      data["order"] = []
      data["phase_type"] = []
      data["data"] = []
      if device_type == "cpu":
          sorted_items = sorted(
              self.operator_items.items(),
              key=lambda x: x[1].cpu_time,
              reverse=True,
          )
  
      else:
          sorted_items = sorted(
              self.operator_items.items(),
              key=lambda x: x[1].general_gpu_time,
              reverse=True,
          )
      if topk <= 0 or topk >= 20:
          items = sorted_items[:20]
          other_items = sorted_items[20:]
      else:
          items = sorted_items[:topk]
          other_items = []
      data["order"].extend(
          ["infer_shape", "compute", "node_creation", "others"]
      )
      inner_op_data = defaultdict(list)
      for op_name, event in items:
          data["phase_type"].append(op_name)
          innerop_knownsub_times = 0
          have_innerop_name = set()
          for innerop_name, item in event.operator_inners.items():
              if (
                  "infer_shape" in innerop_name
                  or "infer_meta" in innerop_name
              ):
                  innerop_name = "infer_shape"
              elif "compute" in innerop_name:
                  innerop_name = "compute"
              elif "node_creation" in innerop_name:
                  innerop_name = "node_creation"
              else:
                  continue
              have_innerop_name.add(innerop_name)
              if device_type == "cpu":
                  inner_op_data[innerop_name].append(
                      format_time(item.cpu_time, time_unit)
                  )
                  innerop_knownsub_times += item.cpu_time
              else:
                  inner_op_data[innerop_name].append(
                      format_time(item.general_gpu_time, time_unit)
                  )
                  innerop_knownsub_times += item.general_gpu_time
          if device_type == "cpu":
              inner_op_data["others"].append(
                  format_time(
                      event.cpu_time - innerop_knownsub_times, time_unit
                  )
              )
          else:
              inner_op_data["others"].append(
                  format_time(
                      event.general_gpu_time - innerop_knownsub_times,
                      time_unit,
                  )
              )
          have_innerop_name.add("others")
          for innerop_name in data["order"]:
              if innerop_name in have_innerop_name:
                  continue
              else:
                  inner_op_data[innerop_name].append(0)
      if other_items:
          innerop_knownsub_times = 0
          total_event_times = 0
          data["phase_type"].append("others")
          others_time = defaultdict(float)
          for op_name, event in other_items:
              for innerop_name, item in event.operator_inners.items():
                  if "infer_shape" in innerop_name:
                      innerop_name = "infer_shape"
                  elif "compute" in innerop_name:
                      innerop_name = "compute"
                  elif "node_creation" in innerop_name:
                      innerop_name = "node_creation"
                  else:
                      continue
                  if device_type == "cpu":
                      others_time[innerop_name] += item.cpu_time
                      innerop_knownsub_times += item.cpu_time
                  else:
                      others_time[innerop_name] += item.general_gpu_time
                      innerop_knownsub_times += item.general_gpu_time
              if device_type == "cpu":
                  total_event_times += event.cpu_time
              else:
                  total_event_times += event.general_gpu_time
          others_time["others"] = (
              total_event_times - innerop_knownsub_times
          )
          for innerop_name in data["order"]:
              if innerop_name not in others_time:
                  others_time[innerop_name] = 0.0
              inner_op_data[innerop_name].append(
                  format_time(others_time[innerop_name], time_unit)
              )
  
      for innerop_name in data["order"]:
          data["data"].append(inner_op_data[innerop_name])
      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 10 for calling the ProfilerData obj's underlying member method code with example usage: obj.get_operator_pie_expand(topk, device_type, time_unit) and returns: data