class_docstr: Assigns weights to each type in the column type tree and attempts to traverse it using a weight percentage threshold.
class_docstr_tok: ["Assigns","weights","to","each","type","in","the","column","type","tree","and","attempts","to","traverse","it","using","a","weight","percentage","threshold","."]
docstr: Get a dict of cumulative weights, starting at `root`.
  
  A parent node's weight is the sum of all its children plus its own weight. Children tagged as only
  applying to their parent are excluded from their grand-parent's sum.
  
  root: the root to start assigning cumulative weights from.
  output_weights: the output dictionary to assign the cumulative weights to
  output_parent_only_weights: similar to output_weights, but the weight of each node excludes the weights
      of all of its parent-only children
  signals_by_type: a dictionary that maps signal type nodes to signals
docstr_tok: ["Get","a","dict","of","cumulative","weights",",","starting","at","`","root","`",".","A","parent","node","'s","weight","is","the","sum","of","all","its","children","plus","its","own","weight",".","Children","tagged","as","only","applying","to","their","parent","are","excluded","from","their","grand-parent","'s","sum",".","root",":","the","root","to","start","assigning","cumulative","weights","from",".","output_weights",":","the","output","dictionary","to","assign","the","cumulative","weights","to","output_parent_only_weights",":","similar","to","output_weights",",","but","the","weight","of","each","node","excludes","the","weights","of","all","of","its","parent-only","children","signals_by_type",":","a","dictionary","that","maps","signal","type","nodes","to","signals"]
code: def _get_cumulative_weights_for_root(
      self,
      root: InferenceSignalNode,
      output_weights: Dict[InferenceSignalNode, int],
      output_parent_only_weights: Dict[InferenceSignalNode, int],
      signals_by_type: Dict[InferenceSignalNode, List[InferenceSignal]],
  ) -> Dict[InferenceSignalNode, int]:
      """Get a dict of cumulative weights, starting at `root`.
  
      A parent node's weight is the sum of all its children plus its own weight. Children tagged as only
      applying to their parent are excluded from their grand-parent's sum.
  
      root: the root to start assigning cumulative weights from.
      output_weights: the output dictionary to assign the cumulative weights to
      output_parent_only_weights: similar to output_weights, but the weight of each node excludes the weights
          of all of its parent-only children
      signals_by_type: a dictionary that maps signal type nodes to signals
      """
      for child in root.children:
          self._get_cumulative_weights_for_root(
              root=child,
              output_weights=output_weights,
              output_parent_only_weights=output_parent_only_weights,
              signals_by_type=signals_by_type,
          )
  
      output_weights[root] = sum(
          self._weighter_function(signal.confidence)
          for signal in signals_by_type[root]
      )
      output_weights[root] += sum(
          output_parent_only_weights[child] for child in root.children
      )
  
      output_parent_only_weights[root] = sum(
          self._weighter_function(signal.confidence)
          for signal in signals_by_type[root]
          if not signal.only_applies_to_parent
      )
  
      return output_weights
  
file_path: metricflow/metricflow/inference/solver/weighted_tree.py
imports: from __future__ import annotations
  from collections import defaultdict
  from typing import Callable, Dict, List, Optional
  from metricflow.dataflow.sql_column import SqlColumn
  from metricflow.inference.models import InferenceResult, InferenceSignal, InferenceSignalConfidence, InferenceSignalNode, InferenceSignalType
  from metricflow.inference.solver.base import InferenceSolver
label_desc: Use image node_id 3 for calling the WeightedTypeTreeInferenceSolver obj's underlying member method code with example usage: obj._get_cumulative_weights_for_root(root, output_weights, output_parent_only_weights, signals_by_type) and returns: output_weights