# Path: tensorflow_constrained_optimization/python/rates/basic_expression.py
# class BasicExpression(helpers.RateObject):
#   def _add_terms(self, source):
#   def _sub_terms(self, source):
#   def __init__(self, terms):
#   def is_differentiable(self):
#   def __mul__(self, scalar):
#   def __rmul__(self, scalar):
#   def __truediv__(self, scalar):
#   def __neg__(self):
#   def __add__(self, other):
#   def __sub__(self, other):
#   def evaluate(self, structure_memoizer):
# 
# 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/helpers.py
# class RateObject(object):
# class UniqueList(RateObject):
# def convert_to_1d_tensor(tensor, name=None):
# def get_num_columns_of_2d_tensor(tensor, name="tensor"):
# def get_num_elements_of_tensor(tensor, name="tensor"):
#   def __init__(self, collection=None, element_type=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):
# 
# Path: tensorflow_constrained_optimization/python/rates/term.py
# class _RatioWeights(helpers.RateObject):
# class Term(helpers.RateObject):
# class TensorTerm(Term):
# class BinaryClassificationTerm(Term):
# class MulticlassTerm(Term):
#   def __init__(self, ratios, num_columns):
#   def ratios(self):
#   def num_columns(self):
#   def ratio(cls, weights, column_coefficients, numerator_predicate,
#             denominator_predicate):
#     def value_fn(weights_value, predicate_value):
#   def __mul__(self, scalar):
#   def __rmul__(self, scalar):
#   def __truediv__(self, scalar):
#   def __neg__(self):
#   def __add__(self, other):
#   def __sub__(self, other):
#   def _evaluate_denominator(self, denominator, structure_memoizer):
#       def update_ops_fn(running_averages_variable, structure_memoizer,
#                         value_memoizer):
#       def average_denominator_weight_fn(running_averages_variable):
#   def evaluate(self, structure_memoizer):
#       def ratio_fn(numerator_value, denominator_value):
#   def is_differentiable(self):
#   def key(self):
#   def __mul__(self, scalar):
#   def __rmul__(self, scalar):
#   def __truediv__(self, scalar):
#   def __neg__(self):
#   def __add__(self, other):
#   def __sub__(self, other):
#   def evaluate(self, structure_memoizer):
#   def __init__(self, tensor):
#   def tensor(self):
#   def is_differentiable(self):
#   def key(self):
#   def __mul__(self, scalar):
#   def __truediv__(self, scalar):
#   def __neg__(self):
#   def __add__(self, other):
#   def __sub__(self, other):
#   def evaluate(self, structure_memoizer):
#   def __init__(self, predictions, ratio_weights, loss):
#   def ratio(cls, positive_coefficient, negative_coefficient, predictions,
#             weights, numerator_predicate, denominator_predicate, loss):
#   def predictions(self):
#   def ratio_weights(self):
#   def loss(self):
#   def is_differentiable(self):
#   def key(self):
#   def __mul__(self, scalar):
#   def __truediv__(self, scalar):
#   def __neg__(self):
#   def __add__(self, other):
#   def __sub__(self, other):
#   def evaluate(self, structure_memoizer):
#     def average_loss_fn(predictions_value, ratio_weights_value):
#   def __init__(self, predictions, ratio_weights, loss):
#   def ratio(cls, coefficients, predictions, weights, numerator_predicate,
#             denominator_predicate, loss):
#   def predictions(self):
#   def ratio_weights(self):
#   def loss(self):
#   def is_differentiable(self):
#   def key(self):
#   def __mul__(self, scalar):
#   def __truediv__(self, scalar):
#   def __neg__(self):
#   def __add__(self, other):
#   def __sub__(self, other):
#   def evaluate(self, structure_memoizer):
#     def average_loss_fn(predictions_value, ratio_weights_value):


import abc
import numbers
import six
from tensorflow_constrained_optimization.python.rates import basic_expression
from tensorflow_constrained_optimization.python.rates import constraint
from tensorflow_constrained_optimization.python.rates import helpers
from tensorflow_constrained_optimization.python.rates import term

  @abc.abstractmethod
  def _positive_scalar_div(self, scalar):
    """Returns the result of dividing by a positive scalar."""
    # This method is intended for internal use only. It's basically the same as
    # __div__, except that it requires its parameter to be positive (this is
    # *not* checked), and accepts non-Number inputs (in particular, it accepts
    # DeferredTensors).

  @abc.abstractmethod
  def __mul__(self, scalar):
    """Returns the result of multiplying by a scalar."""

  def __rmul__(self, scalar):
    """Returns the result of multiplying by a scalar."""
    return self.__mul__(scalar)

  @abc.abstractmethod
  def __truediv__(self, scalar):
    """Returns the result of dividing by a scalar."""

  # __rtruediv__ is not implemented since we only allow *scalar* division, i.e.
  # (Expression / scalar) is allowed, but (scalar / Expression) is not.

  @abc.abstractmethod
  def __neg__(self):
    """Returns the result of negating this `Expression`."""

  def __add__(self, other):
    """Returns the result of adding two `Expression`s."""

# Path: tensorflow_constrained_optimization/python/rates/basic_expression.py
# class BasicExpression(helpers.RateObject):
#   def _add_terms(self, source):
#   def _sub_terms(self, source):
#   def __init__(self, terms):
#   def is_differentiable(self):
#   def __mul__(self, scalar):
#   def __rmul__(self, scalar):
#   def __truediv__(self, scalar):
#   def __neg__(self):
#   def __add__(self, other):
#   def __sub__(self, other):
#   def evaluate(self, structure_memoizer):
# 
# 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/helpers.py
# class RateObject(object):
# class UniqueList(RateObject):
# def convert_to_1d_tensor(tensor, name=None):
# def get_num_columns_of_2d_tensor(tensor, name="tensor"):
# def get_num_elements_of_tensor(tensor, name="tensor"):
#   def __init__(self, collection=None, element_type=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):
# 
# Path: tensorflow_constrained_optimization/python/rates/term.py
# class _RatioWeights(helpers.RateObject):
# class Term(helpers.RateObject):
# class TensorTerm(Term):
# class BinaryClassificationTerm(Term):
# class MulticlassTerm(Term):
#   def __init__(self, ratios, num_columns):
#   def ratios(self):
#   def num_columns(self):
#   def ratio(cls, weights, column_coefficients, numerator_predicate,
#             denominator_predicate):
#     def value_fn(weights_value, predicate_value):
#   def __mul__(self, scalar):
#   def __rmul__(self, scalar):
#   def __truediv__(self, scalar):
#   def __neg__(self):
#   def __add__(self, other):
#   def __sub__(self, other):
#   def _evaluate_denominator(self, denominator, structure_memoizer):
#       def update_ops_fn(running_averages_variable, structure_memoizer,
#                         value_memoizer):
#       def average_denominator_weight_fn(running_averages_variable):
#   def evaluate(self, structure_memoizer):
#       def ratio_fn(numerator_value, denominator_value):
#   def is_differentiable(self):
#   def key(self):
#   def __mul__(self, scalar):
#   def __rmul__(self, scalar):
#   def __truediv__(self, scalar):
#   def __neg__(self):
#   def __add__(self, other):
#   def __sub__(self, other):
#   def evaluate(self, structure_memoizer):
#   def __init__(self, tensor):
#   def tensor(self):
#   def is_differentiable(self):
#   def key(self):
#   def __mul__(self, scalar):
#   def __truediv__(self, scalar):
#   def __neg__(self):
#   def __add__(self, other):
#   def __sub__(self, other):
#   def evaluate(self, structure_memoizer):
#   def __init__(self, predictions, ratio_weights, loss):
#   def ratio(cls, positive_coefficient, negative_coefficient, predictions,
#             weights, numerator_predicate, denominator_predicate, loss):
#   def predictions(self):
#   def ratio_weights(self):
#   def loss(self):
#   def is_differentiable(self):
#   def key(self):
#   def __mul__(self, scalar):
#   def __truediv__(self, scalar):
#   def __neg__(self):
#   def __add__(self, other):
#   def __sub__(self, other):
#   def evaluate(self, structure_memoizer):
#     def average_loss_fn(predictions_value, ratio_weights_value):
#   def __init__(self, predictions, ratio_weights, loss):
#   def ratio(cls, coefficients, predictions, weights, numerator_predicate,
#             denominator_predicate, loss):
#   def predictions(self):
#   def ratio_weights(self):
#   def loss(self):
#   def is_differentiable(self):
#   def key(self):
#   def __mul__(self, scalar):
#   def __truediv__(self, scalar):
#   def __neg__(self):
#   def __add__(self, other):
#   def __sub__(self, other):
#   def evaluate(self, structure_memoizer):
#     def average_loss_fn(predictions_value, ratio_weights_value):


# Path: tensorflow_constrained_optimization/python/rates/expression.py
import abc
import numbers
import six
from tensorflow_constrained_optimization.python.rates import basic_expression
from tensorflow_constrained_optimization.python.rates import constraint
from tensorflow_constrained_optimization.python.rates import helpers
from tensorflow_constrained_optimization.python.rates import term


  @abc.abstractmethod
  def _positive_scalar_div(self, scalar):
    """Returns the result of dividing by a positive scalar."""
    # This method is intended for internal use only. It's basically the same as
    # __div__, except that it requires its parameter to be positive (this is
    # *not* checked), and accepts non-Number inputs (in particular, it accepts
    # DeferredTensors).

  @abc.abstractmethod
  def __mul__(self, scalar):
    """Returns the result of multiplying by a scalar."""

  def __rmul__(self, scalar):
    """Returns the result of multiplying by a scalar."""
    return self.__mul__(scalar)

  @abc.abstractmethod
  def __truediv__(self, scalar):
    """Returns the result of dividing by a scalar."""

  # __rtruediv__ is not implemented since we only allow *scalar* division, i.e.
  # (Expression / scalar) is allowed, but (scalar / Expression) is not.

  @abc.abstractmethod
  def __neg__(self):
    """Returns the result of negating this `Expression`."""

  def __add__(self, other):
    """Returns the result of adding two `Expression`s."""

    if not isinstance(other, helpers.RateObject):