# Path: tensorflow_constrained_optimization/python/graph_and_eager_test_case.py
# class _EagerPlaceholder(object):
# class _GraphWrappedSession(object):
# class _EagerWrappedSession(object):
# class GraphAndEagerTestCase(tf.test.TestCase):
#   def __init__(self):
#   def set(self, tensor):
#   def __call__(self):
#   def __init__(self, session):
#   def __enter__(self):
#   def __exit__(self, exc_type, exc_value, traceback):
#   def run(self, tensor, feed_dict=None):
#   def run_ops(self, callback, feed_dict=None):
#   def __init__(self):
#   def __enter__(self):
#   def __exit__(self, exc_type, exc_value, traceback):
#   def run(self, tensor, feed_dict=None):
#   def run_ops(self, callback, feed_dict=None):
#   def wrapped_placeholder(self, dtype, shape=None, name=None):
#   def wrapped_session(self):
# 
# 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 numpy as np
import tensorflow as tf
from tensorflow_constrained_optimization.python import graph_and_eager_test_case
from tensorflow_constrained_optimization.python.rates import defaults
from tensorflow_constrained_optimization.python.rates import deferred_tensor
    self.assertEqual(tf.float64, value7.dtype.base_dtype)

    with self.wrapped_session() as session:
      self.assertAllClose(-2, session.run(value1))
      self.assertAllClose(1.5, session.run(value2))
      self.assertAllClose(2.7, session.run(value3))
      self.assertAllClose(0.3, session.run(value4))
      self.assertAllClose(-0.5, session.run(value5))
      self.assertAllClose(9, session.run(value6))
      self.assertAllClose(-4.5, session.run(value7))

  def test_callable(self):
    """Tests that callbacks are not called until needed."""
    # Keeps track of whether the callbacks have been called.
    structure_memoizer = {
        defaults.DENOMINATOR_LOWER_BOUND_KEY: 0.0,
        defaults.GLOBAL_STEP_KEY: tf.Variable(0, dtype=tf.int32),
        defaults.VARIABLE_FN_KEY: tf.Variable
    }

    callback_list = []

    def callback1():
      callback_list.append("callback1")
      return 3.14

    def callback2():
      callback_list.append("callback2")
      return 4


# Path: tensorflow_constrained_optimization/python/graph_and_eager_test_case.py
# class _EagerPlaceholder(object):
# class _GraphWrappedSession(object):
# class _EagerWrappedSession(object):
# class GraphAndEagerTestCase(tf.test.TestCase):
#   def __init__(self):
#   def set(self, tensor):
#   def __call__(self):
#   def __init__(self, session):
#   def __enter__(self):
#   def __exit__(self, exc_type, exc_value, traceback):
#   def run(self, tensor, feed_dict=None):
#   def run_ops(self, callback, feed_dict=None):
#   def __init__(self):
#   def __enter__(self):
#   def __exit__(self, exc_type, exc_value, traceback):
#   def run(self, tensor, feed_dict=None):
#   def run_ops(self, callback, feed_dict=None):
#   def wrapped_placeholder(self, dtype, shape=None, name=None):
#   def wrapped_session(self):
# 
# 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/deferred_tensor_test.py
import numpy as np
import tensorflow as tf
from tensorflow_constrained_optimization.python import graph_and_eager_test_case
from tensorflow_constrained_optimization.python.rates import defaults
from tensorflow_constrained_optimization.python.rates import deferred_tensor

    self.assertEqual(tf.float64, value7.dtype.base_dtype)

    with self.wrapped_session() as session:
      self.assertAllClose(-2, session.run(value1))
      self.assertAllClose(1.5, session.run(value2))
      self.assertAllClose(2.7, session.run(value3))
      self.assertAllClose(0.3, session.run(value4))
      self.assertAllClose(-0.5, session.run(value5))
      self.assertAllClose(9, session.run(value6))
      self.assertAllClose(-4.5, session.run(value7))

  def test_callable(self):
    """Tests that callbacks are not called until needed."""
    # Keeps track of whether the callbacks have been called.
    structure_memoizer = {
        defaults.DENOMINATOR_LOWER_BOUND_KEY: 0.0,
        defaults.GLOBAL_STEP_KEY: tf.Variable(0, dtype=tf.int32),
        defaults.VARIABLE_FN_KEY: tf.Variable
    }

    callback_list = []

    def callback1():
      callback_list.append("callback1")
      return 3.14

    def callback2():
      callback_list.append("callback2")
      return 4


    tensor1 = deferred_tensor.ExplicitDeferredTensor(callback1)