parameters: (self, op_name, task_fops)
docstring: Add task_fops to each scope of the op_name.
  
          The top-level scope name is "Default" or "recompute_Default" or "Gradients".
          To classify the same scope name under different top-level scope, a suffix name is added.
          For op_name like "Default/network", the "network" will be renamed as "network(Default)".
          For op_name like "recompute_Default/network", "network" --> "network(recompute_Default)".
          For op_name like "Gradients/network", "network" --> "network(Gradients)".
          For op_name like "Gradients/recompute_Default/network"，"network" --> "network(recompute_Gradients)".
docstring_summary: Add task_fops to each scope of the op_name.
docstring_tokens: Add task_fops to each scope of the op_name .
function: def _add_flops_to_each_scope(self, op_name, task_fops):
          """
          Add task_fops to each scope of the op_name.
  
          The top-level scope name is "Default" or "recompute_Default" or "Gradients".
          To classify the same scope name under different top-level scope, a suffix name is added.
          For op_name like "Default/network", the "network" will be renamed as "network(Default)".
          For op_name like "recompute_Default/network", "network" --> "network(recompute_Default)".
          For op_name like "Gradients/network", "network" --> "network(Gradients)".
          For op_name like "Gradients/recompute_Default/network"，"network" --> "network(recompute_Gradients)".
          """
          # Only extracts the scope name, remove the operator name.
          scope_list = op_name.split('/')[:-1]
          self._max_scope_num = max(self._max_scope_num, len(scope_list))
          top_level_scope = scope_list[0]
          suffix_name = ""
          if op_name.startswith("Gradients/recompute_Default"):
              suffix_name = "recompute_Gradients"
          else:
              suffix_name = top_level_scope
          # To distinguish the same scope name at different scope level and different top level scope,
          # the scope level and top level scope is added.
          for level, scope_name in enumerate(scope_list):
              scope_list[level] = scope_name + f"({level}_{suffix_name})"
          scope_list[0] = top_level_scope
  
          # Add root node (refers to total flops).
          scope_list.insert(0, "Total")
          scope_depth = len(scope_list)
          for idx in range(scope_depth - 1):
              key_name = scope_list[idx] + " " + scope_list[idx + 1]
              self._flops_each_scope.setdefault(key_name, 0)
              self._flops_each_scope[key_name] += task_fops
function_tokens: def _add_flops_to_each_scope ( self , op_name , task_fops ) : # Only extracts the scope name, remove the operator name. scope_list = op_name . split ( '/' ) [ : - 1 ] self . _max_scope_num = max ( self . _max_scope_num , len ( scope_list ) ) top_level_scope = scope_list [ 0 ] suffix_name = "" if op_name . startswith ( "Gradients/recompute_Default" ) : suffix_name = "recompute_Gradients" else : suffix_name = top_level_scope # To distinguish the same scope name at different scope level and different top level scope, # the scope level and top level scope is added. for level , scope_name in enumerate ( scope_list ) : scope_list [ level ] = scope_name + f"({level}_{suffix_name})" scope_list [ 0 ] = top_level_scope # Add root node (refers to total flops). scope_list . insert ( 0 , "Total" ) scope_depth = len ( scope_list ) for idx in range ( scope_depth - 1 ) : key_name = scope_list [ idx ] + " " + scope_list [ idx + 1 ] self . _flops_each_scope . setdefault ( key_name , 0 ) self . _flops_each_scope [ key_name ] += task_fops