class_docstr: This simple profiler records the duration of model prediction in seconds,
  and compute the net percentage duration of each sub models via 'model_dependencies'.
  Usage:
      model = modelkit.load_model(...)
      profiler = SimpleProfiler(model)
      res = model(item)
      profiler.summary() # return profiling result (Dict) or str
  
  Attributes:
      recording_hook (Dict[str, float]): record start/end time of each model call
      durations (List[float]): record duration of each model call
      net_durations (List[float]): record net duration of each model call. Net
          duration is the duration minus all the other sub models' duration.
      graph (Dict[str, Set]): model dependencies graph, get all direct children names
          (Set[str])
      graph_calls (Dict[str, Dict[str, int]]): record all model calls
          e.g
          {
              "pipeline": {
                  "__main__": 1, # "pipeline" is called once
                  "model_a": 2,
                  "model_b": 1,
                  "model_c": 1,
              }
          }
  See test_simple_profiler.py for more details.
class_docstr_tok: ["This","simple","profiler","records","the","duration","of","model","prediction","in","seconds",",","and","compute","the","net","percentage","duration","of","each","sub","models","via","'model_dependencies","'",".","Usage",":","model","=","modelkit.load_model","(","...",")","profiler","=","SimpleProfiler","(","model",")","res","=","model","(","item",")","profiler.summary","(",")","#","return","profiling","result","(","Dict",")","or","str","Attributes",":","recording_hook","(","Dict","[","str",",","float","]",")",":","record","start\/end","time","of","each","model","call","durations","(","List","[","float","]",")",":","record","duration","of","each","model","call","net_durations","(","List","[","float","]",")",":","record","net","duration","of","each","model","call",".","Net","duration","is","the","duration","minus","all","the","other","sub","models","'","duration",".","graph","(","Dict","[","str",",","Set","]",")",":","model","dependencies","graph",",","get","all","direct","children","names","(","Set","[","str","]",")","graph_calls","(","Dict","[","str",",","Dict","[","str",",","int","]","]",")",":","record","all","model","calls","e.g","{","``","pipeline","''",":","{","``","__main__","''",":","1",",","#","``","pipeline","''","is","called","once","``","model_a","''",":","2",",","``","model_b","''",":","1",",","``","model_c","''",":","1",",","}","}","See","test_simple_profiler.py","for","more","details","."]
docstr: Compute net cost of each sub models. Subtracting model "duration" by
  "duration" of all direct sub model.
  
  Args:
      duration (float): model duration
      sub_calls (Dict[str, int]): number of calls of all sub_model
  
  Returns:
      float: net cost
docstr_tok: ["Compute","net","cost","of","each","sub","models",".","Subtracting","model","``","duration","''","by","''","duration","''","of","all","direct","sub","model",".","Args",":","duration","(","float",")",":","model","duration","sub_calls","(","Dict","[","str",",","int","]",")",":","number","of","calls","of","all","sub_model","Returns",":","float",":","net","cost"]
code: def _calculate_net_cost(
      self, duration: float, sub_calls: Dict[str, int]
  ) -> float:
      """Compute net cost of each sub models. Subtracting model "duration" by
      "duration" of all direct sub model.
  
      Args:
          duration (float): model duration
          sub_calls (Dict[str, int]): number of calls of all sub_model
  
      Returns:
          float: net cost
      """
      net_duration = duration
      for sub_model, num_calls in sub_calls.items():
          if sub_model == "__main__":
              continue
          if num_calls > 0:
              net_duration -= sum(
                  self.net_durations[sub_model][-num_calls:]
              )
      return net_duration
  
file_path: modelkit/modelkit/core/profilers/simple.py
imports: import time
  from collections import OrderedDict, defaultdict
  from contextlib import contextmanager
  from typing import Dict, Generator, List, Set, Union
  from tabulate import tabulate
  from modelkit.core.model import Model
  from modelkit.core.profilers.base import BaseProfiler
label_desc: Use image node_id 9 for calling the SimpleProfiler obj's underlying member method code with example usage: obj._calculate_net_cost(duration, sub_calls) and returns: net_duration