# 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):


import tensorflow as tf
from tensorflow_constrained_optimization.python.rates import deferred_tensor
from tensorflow_constrained_optimization.python.rates import helpers
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
# ==============================================================================
"""Contains the `Predicate` class."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function




class Predicate(helpers.RateObject):
  """Object representing a boolean predicate.

  We actually support *soft* predicates: the wrapped `Tensor` is allowed to take
  on values between zero and one, not just the two extremes.
  """

  @classmethod
  def _convert_and_clip_fn(cls, arg):
    """Converts the given object to a rank-one float32 `Tensor` in [0,1]."""
    return tf.clip_by_value(
        tf.cast(

# 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
import tensorflow as tf
from tensorflow_constrained_optimization.python.rates import deferred_tensor
from tensorflow_constrained_optimization.python.rates import helpers

#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
# ==============================================================================
"""Contains the `Predicate` class."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function




class Predicate(helpers.RateObject):
  """Object representing a boolean predicate.

  We actually support *soft* predicates: the wrapped `Tensor` is allowed to take
  on values between zero and one, not just the two extremes.
  """

  @classmethod
  def _convert_and_clip_fn(cls, arg):
    """Converts the given object to a rank-one float32 `Tensor` in [0,1]."""
    return tf.clip_by_value(
        tf.cast(

            helpers.convert_to_1d_tensor(arg, "predicate"), dtype=tf.float32),