# Path: tensorflow_constrained_optimization/python/constrained_minimization_problem.py
# class ConstrainedMinimizationProblem(tf.Module):
#   def __init__(self, name=None):
#   def objective(self):
#   def num_constraints(self):
#   def constraints(self):
#   def proxy_constraints(self):
#   def components(self):
#   def update_ops(self):
# 
# Path: tensorflow_constrained_optimization/python/rates/constraint.py
# class Constraint(helpers.RateObject):
# class ConstraintList(helpers.UniqueList):
#   def __init__(self, expression):
#   def expression(self):
#   def __init__(self, collection=None):
# 
# Path: tensorflow_constrained_optimization/python/rates/defaults.py
# DENOMINATOR_LOWER_BOUND_KEY = "denominator_lower_bound"
# GLOBAL_STEP_KEY = "global_step"
# VARIABLE_FN_KEY = "variable_fn"
# DEFAULT_PENALTY_LOSS = loss.HingeLoss()
# DEFAULT_CONSTRAINT_LOSS = loss.ZeroOneLoss()
# 
# Path: tensorflow_constrained_optimization/python/rates/deferred_tensor.py
# class _DeferredTensorInput(helpers.RateObject):
# class DeferredTensor(helpers.RateObject):
# class _DerivedDeferredTensor(DeferredTensor):
# class ExplicitDeferredTensor(DeferredTensor):
# class DeferredVariable(DeferredTensor):
# class DeferredTensorInputList(helpers.RateObject):
# class DeferredVariableList(helpers.UniqueList):
#   def _list_to_tuple(cls, arg):
#   def __init__(self, value):
#   def value(self):
#   def __hash__(self):
#   def __eq__(self, other):
#   def __ne__(self, other):
#   def _value_and_auto_cast(self, structure_memoizer, value_memoizer):
#   def inputs(self):
#   def variables(self):
#   def __hash__(self):
#   def __eq__(self, other):
#   def __ne__(self, other):
#   def __call__(self, structure_memoizer, value_memoizer=None):
#   def apply(cls, callback, *args):
#   def __neg__(self):
#   def __lt__(self, other):
#   def __le__(self, other):
#   def __gt__(self, other):
#   def __ge__(self, other):
#   def __add__(self, other):
#   def __radd__(self, other):
#   def __sub__(self, other):
#   def __rsub__(self, other):
#   def __mul__(self, other):
#   def __rmul__(self, other):
#   def __truediv__(self, other):
#   def __rtruediv__(self, other):
#   def __getitem__(self, slice_spec):
#   def __init__(self, callback, args):
#   def _value_and_auto_cast(self, structure_memoizer, value_memoizer):
#   def inputs(self):
#   def variables(self):
#   def __hash__(self):
#   def __eq__(self, other):
#   def __init__(self, value, auto_cast=False):
#   def _value_and_auto_cast(self, structure_memoizer, value_memoizer):
#   def inputs(self):
#   def variables(self):
#   def __hash__(self):
#   def __eq__(self, other):
#   def __init__(self,
#                initial_value,
#                trainable=None,
#                name=None,
#                dtype=None,
#                constraint=None,
#                update_ops_fn=None,
#                auto_cast=False):
#   def _value_and_auto_cast(self, structure_memoizer, value_memoizer):
#   def inputs(self):
#   def variables(self):
#   def __hash__(self):
#   def __eq__(self, other):
#   def create(self, structure_memoizer):
#   def update_ops(self, structure_memoizer, value_memoizer=None):
#   def __init__(self, collection=None):
#   def list(self):
#   def append(self, element):
#   def __eq__(self, other):
#   def __ne__(self, other):
#   def __len__(self):
#   def __iter__(self):
#   def __add__(self, other):
#   def __radd__(self, other):
#   def __getitem__(self, slice_spec):
#   def __init__(self, collection=None):


import tensorflow as tf
from tensorflow_constrained_optimization.python import constrained_minimization_problem
from tensorflow_constrained_optimization.python.rates import constraint
from tensorflow_constrained_optimization.python.rates import defaults
from tensorflow_constrained_optimization.python.rates import deferred_tensor
    constrained_minimization_problem.ConstrainedMinimizationProblem):
  """A rate constrained optimization problem.

  In order to optimize a rate constrained problem, you should construct an
  instance of this class from the objective function that you wish to minimize
  and the list of constraints you wish to impose. This class implements the
  `ConstrainedMinimizationProblem` interface, so the resulting object can then
  be optimized using a `ConstrainedOptimizerV1` or `ConstrainedOptimizerV2`.

  It's important to understand that this object is *stateful*. In addition to
  slack variables (which are automatically inserted for certain rates), the
  denominators of the rates are estimated from running sums over all of the data
  that has been seen by update_ops (which will be executed at the start of every
  train_op). Hence, these estimated denominators--upon which the objective,
  constraints and proxy_constraints `Tensor`s depend--will change from
  iteration-to-iteration as they converge to their true values.
  """

  # We handle variables in a sort of roundabout manner: each DeferredVariable
  # has an associated key, which maps (in the structure memoizer) to the
  # tf.Variable itself. However, since dicts with tuple keys cannot be tracked
  # by tf.Trackable (upon which tf.Module is based), "self._structure_memoizer"
  # is excluded from tracking via "self._no_dependency".
  #
  #
  # Unfortunately, "self._no_dependency" only handles tf.Trackable dependencies,
  # and tf.Module also encounters issues when flattening dictionaries with
  # mixed-type keys, so to exclude "self._structure_memoizer" from tf.Module
  # tracking, we also need to add it to the folowing list:
  _TF_MODULE_IGNORED_PROPERTIES = (

# Path: tensorflow_constrained_optimization/python/constrained_minimization_problem.py
# class ConstrainedMinimizationProblem(tf.Module):
#   def __init__(self, name=None):
#   def objective(self):
#   def num_constraints(self):
#   def constraints(self):
#   def proxy_constraints(self):
#   def components(self):
#   def update_ops(self):
# 
# Path: tensorflow_constrained_optimization/python/rates/constraint.py
# class Constraint(helpers.RateObject):
# class ConstraintList(helpers.UniqueList):
#   def __init__(self, expression):
#   def expression(self):
#   def __init__(self, collection=None):
# 
# Path: tensorflow_constrained_optimization/python/rates/defaults.py
# DENOMINATOR_LOWER_BOUND_KEY = "denominator_lower_bound"
# GLOBAL_STEP_KEY = "global_step"
# VARIABLE_FN_KEY = "variable_fn"
# DEFAULT_PENALTY_LOSS = loss.HingeLoss()
# DEFAULT_CONSTRAINT_LOSS = loss.ZeroOneLoss()
# 
# Path: tensorflow_constrained_optimization/python/rates/deferred_tensor.py
# class _DeferredTensorInput(helpers.RateObject):
# class DeferredTensor(helpers.RateObject):
# class _DerivedDeferredTensor(DeferredTensor):
# class ExplicitDeferredTensor(DeferredTensor):
# class DeferredVariable(DeferredTensor):
# class DeferredTensorInputList(helpers.RateObject):
# class DeferredVariableList(helpers.UniqueList):
#   def _list_to_tuple(cls, arg):
#   def __init__(self, value):
#   def value(self):
#   def __hash__(self):
#   def __eq__(self, other):
#   def __ne__(self, other):
#   def _value_and_auto_cast(self, structure_memoizer, value_memoizer):
#   def inputs(self):
#   def variables(self):
#   def __hash__(self):
#   def __eq__(self, other):
#   def __ne__(self, other):
#   def __call__(self, structure_memoizer, value_memoizer=None):
#   def apply(cls, callback, *args):
#   def __neg__(self):
#   def __lt__(self, other):
#   def __le__(self, other):
#   def __gt__(self, other):
#   def __ge__(self, other):
#   def __add__(self, other):
#   def __radd__(self, other):
#   def __sub__(self, other):
#   def __rsub__(self, other):
#   def __mul__(self, other):
#   def __rmul__(self, other):
#   def __truediv__(self, other):
#   def __rtruediv__(self, other):
#   def __getitem__(self, slice_spec):
#   def __init__(self, callback, args):
#   def _value_and_auto_cast(self, structure_memoizer, value_memoizer):
#   def inputs(self):
#   def variables(self):
#   def __hash__(self):
#   def __eq__(self, other):
#   def __init__(self, value, auto_cast=False):
#   def _value_and_auto_cast(self, structure_memoizer, value_memoizer):
#   def inputs(self):
#   def variables(self):
#   def __hash__(self):
#   def __eq__(self, other):
#   def __init__(self,
#                initial_value,
#                trainable=None,
#                name=None,
#                dtype=None,
#                constraint=None,
#                update_ops_fn=None,
#                auto_cast=False):
#   def _value_and_auto_cast(self, structure_memoizer, value_memoizer):
#   def inputs(self):
#   def variables(self):
#   def __hash__(self):
#   def __eq__(self, other):
#   def create(self, structure_memoizer):
#   def update_ops(self, structure_memoizer, value_memoizer=None):
#   def __init__(self, collection=None):
#   def list(self):
#   def append(self, element):
#   def __eq__(self, other):
#   def __ne__(self, other):
#   def __len__(self):
#   def __iter__(self):
#   def __add__(self, other):
#   def __radd__(self, other):
#   def __getitem__(self, slice_spec):
#   def __init__(self, collection=None):


# Path: tensorflow_constrained_optimization/python/rates/rate_minimization_problem.py
import tensorflow as tf
from tensorflow_constrained_optimization.python import constrained_minimization_problem
from tensorflow_constrained_optimization.python.rates import constraint
from tensorflow_constrained_optimization.python.rates import defaults
from tensorflow_constrained_optimization.python.rates import deferred_tensor

    constrained_minimization_problem.ConstrainedMinimizationProblem):
  """A rate constrained optimization problem.

  In order to optimize a rate constrained problem, you should construct an
  instance of this class from the objective function that you wish to minimize
  and the list of constraints you wish to impose. This class implements the
  `ConstrainedMinimizationProblem` interface, so the resulting object can then
  be optimized using a `ConstrainedOptimizerV1` or `ConstrainedOptimizerV2`.

  It's important to understand that this object is *stateful*. In addition to
  slack variables (which are automatically inserted for certain rates), the
  denominators of the rates are estimated from running sums over all of the data
  that has been seen by update_ops (which will be executed at the start of every
  train_op). Hence, these estimated denominators--upon which the objective,
  constraints and proxy_constraints `Tensor`s depend--will change from
  iteration-to-iteration as they converge to their true values.
  """

  # We handle variables in a sort of roundabout manner: each DeferredVariable
  # has an associated key, which maps (in the structure memoizer) to the
  # tf.Variable itself. However, since dicts with tuple keys cannot be tracked
  # by tf.Trackable (upon which tf.Module is based), "self._structure_memoizer"
  # is excluded from tracking via "self._no_dependency".
  #
  #
  # Unfortunately, "self._no_dependency" only handles tf.Trackable dependencies,
  # and tf.Module also encounters issues when flattening dictionaries with
  # mixed-type keys, so to exclude "self._structure_memoizer" from tf.Module
  # tracking, we also need to add it to the folowing list:
  _TF_MODULE_IGNORED_PROPERTIES = (

      constrained_minimization_problem.ConstrainedMinimizationProblem