class_docstr: Manages the privacy budget.
class_docstr_tok: ["Manages","the","privacy","budget","."]
docstr: Updates all previously requested MechanismSpec objects with corresponding budget values.
docstr_tok: ["Updates","all","previously","requested","MechanismSpec","objects","with","corresponding","budget","values","."]
code: def compute_budgets(self):
      """Updates all previously requested MechanismSpec objects with corresponding budget values."""
      self._check_aggregation_restrictions()
      self._finalize()
  
      if not self._mechanisms:
          logging.warning("No budgets were requested.")
          return
  
      if self._scopes_stack:
          raise Exception(
              "Cannot call compute_budgets from within a budget scope."
          )
  
      total_weight_eps = total_weight_delta = 0
      for mechanism in self._mechanisms:
          total_weight_eps += (
              mechanism.weight * mechanism.mechanism_spec.count
          )
          if mechanism.mechanism_spec.use_delta():
              total_weight_delta += (
                  mechanism.weight * mechanism.mechanism_spec.count
              )
  
      for mechanism in self._mechanisms:
          eps = delta = 0
          if total_weight_eps:
              numerator = self._total_epsilon * mechanism.weight
              eps = numerator / total_weight_eps
          if mechanism.mechanism_spec.use_delta():
              if total_weight_delta:
                  numerator = self._total_delta * mechanism.weight
                  delta = numerator / total_weight_delta
          mechanism.mechanism_spec.set_eps_delta(eps, delta)
  
imports: import abc
  import collections
  import logging
  import math
  from typing import Optional
  from dataclasses import dataclass
  import pipeline_dp.aggregate_params
  from pipeline_dp import input_validators
label_desc: Use image node_id 3 for calling the NaiveBudgetAccountant obj's underlying member method code with example usage: obj.compute_budgets() without return types