# 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/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/predicate.py
# class Predicate(helpers.RateObject):
#   def _convert_and_clip_fn(cls, arg):
#   def _invert_fn(cls, tensor):
#   def __init__(  # pylint: disable=invalid-name
#       self, tensor, _convert_and_clip=True):
#   def tensor(self):
#   def __hash__(self):
#   def __eq__(self, other):
#   def __ne__(self, other):
#   def __invert__(self):
#   def __and__(self, other):
#   def __or__(self, other):
#   def __xor__(self, other):


import numbers
import tensorflow as tf
from tensorflow_constrained_optimization.python.rates import deferred_tensor
from tensorflow_constrained_optimization.python.rates import helpers
from tensorflow_constrained_optimization.python.rates import predicate
      are not callable, *or* if any arguments are internal rate library objects,
      instead of `Tensor`s or scalars.
  """
  return _rate_context_helper(
      predictions=predictions,
      labels=labels,
      weights=weights,
      labels_are_probabilities=True,
      num_classes=num_classes)


def _split_rate_context_helper(penalty_predictions, constraint_predictions,
                               penalty_labels, constraint_labels,
                               penalty_weights, constraint_weights,
                               labels_are_probabilities, num_classes):
  """Helper for split_rate_context() and multiclass_split_rate_context()."""

  # See comment in _rate_context_helper.
  if isinstance(penalty_predictions, helpers.RateObject):
    raise TypeError("penalty_predictions parameter to split_rate_context() "
                    "should be a Tensor-like object, or a nullary function "
                    "returning such")
  if isinstance(constraint_predictions, helpers.RateObject):
    raise TypeError("constraint_predictions parameter to split_rate_context() "
                    "should be a Tensor-like object, or a nullary function "
                    "returning such")
  if isinstance(penalty_labels, helpers.RateObject):
    raise TypeError("penalty_labels parameter to split_rate_context() should "
                    "be a Tensor-like object, or a nullary function returning "
                    "such")

# 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/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/predicate.py
# class Predicate(helpers.RateObject):
#   def _convert_and_clip_fn(cls, arg):
#   def _invert_fn(cls, tensor):
#   def __init__(  # pylint: disable=invalid-name
#       self, tensor, _convert_and_clip=True):
#   def tensor(self):
#   def __hash__(self):
#   def __eq__(self, other):
#   def __ne__(self, other):
#   def __invert__(self):
#   def __and__(self, other):
#   def __or__(self, other):
#   def __xor__(self, other):


# Path: tensorflow_constrained_optimization/python/rates/subsettable_context.py
import numbers
import tensorflow as tf
from tensorflow_constrained_optimization.python.rates import deferred_tensor
from tensorflow_constrained_optimization.python.rates import helpers
from tensorflow_constrained_optimization.python.rates import predicate

      are not callable, *or* if any arguments are internal rate library objects,
      instead of `Tensor`s or scalars.
  """
  return _rate_context_helper(
      predictions=predictions,
      labels=labels,
      weights=weights,
      labels_are_probabilities=True,
      num_classes=num_classes)


def _split_rate_context_helper(penalty_predictions, constraint_predictions,
                               penalty_labels, constraint_labels,
                               penalty_weights, constraint_weights,
                               labels_are_probabilities, num_classes):
  """Helper for split_rate_context() and multiclass_split_rate_context()."""

  # See comment in _rate_context_helper.
  if isinstance(penalty_predictions, helpers.RateObject):
    raise TypeError("penalty_predictions parameter to split_rate_context() "
                    "should be a Tensor-like object, or a nullary function "
                    "returning such")
  if isinstance(constraint_predictions, helpers.RateObject):
    raise TypeError("constraint_predictions parameter to split_rate_context() "
                    "should be a Tensor-like object, or a nullary function "
                    "returning such")
  if isinstance(penalty_labels, helpers.RateObject):
    raise TypeError("penalty_labels parameter to split_rate_context() should "
                    "be a Tensor-like object, or a nullary function returning "
                    "such")

  if isinstance(constraint_labels, helpers.RateObject):