# 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/keras.py
# class KerasPlaceholder(object):
# class _KerasInitializer(tf.keras.initializers.Initializer):
# class KerasLayer(tf.keras.layers.Layer):
# class KerasMetricWrapper(tf.keras.metrics.Metric):
#   def __init__(self, callback):
#   def __call__(self):
#   def assign(self, y_true=None, y_pred=None):
#   def __init__(self, value):
#   def __call__(self, shape, dtype=None):
#   def get_config(self):
#   def __init__(self,
#                objective=None,
#                constraints=None,
#                placeholders=None,
#                name=None,
#                denominator_lower_bound=1e-3,
#                loss_creator=lagrangian_optimizer.create_lagrangian_loss,
#                **kwargs):
#   def _variable_fn(self, initial_value, **kwargs):
#   def loss(self, y_true, y_pred):
#   def get_config(self):
#   def __init__(self,
#                wrapped,
#                predictions=None,
#                labels=None,
#                from_logits=False,
#                name=None,
#                **kwargs):
#   def update_state(self, y_true, y_pred, **kwargs):
#   def reset_states(self):
#   def result(self):
# 
# Path: tensorflow_constrained_optimization/python/rates/operations.py
# def wrap_rate(penalty_tensor, constraint_tensor=None):
# def upper_bound(expressions):
# def lower_bound(expressions):


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 keras
from tensorflow_constrained_optimization.python.rates import operations
    self._last_method = "reset_states"

  def result(self):
    self._last_method = "result"
    return 0


# @run_all_tests_in_graph_and_eager_modes
class KerasTest(graph_and_eager_test_case.GraphAndEagerTestCase):
  """Tests for classes in keras.py."""

  def test_keras_placeholder(self):
    """Tests the `KerasPlaceholder` class."""
    y_pred_placeholder = keras.KerasPlaceholder(lambda y_true, y_pred: y_pred)
    y_true_placeholder = keras.KerasPlaceholder(lambda y_true, y_pred: y_true)

    y_pred_placeholder.assign(-2.0, -1.0)
    y_true_placeholder.assign(1.0, 2.0)
    self.assertEqual(-1.0, y_pred_placeholder())
    self.assertEqual(1.0, y_true_placeholder())

    y_pred_placeholder.assign()
    y_true_placeholder.assign()
    with self.assertRaises(RuntimeError):
      _ = y_pred_placeholder()
    with self.assertRaises(RuntimeError):
      _ = y_true_placeholder()

  def test_keras_layer(self):
    """Tests the `KerasLayer` class."""

# 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/keras.py
# class KerasPlaceholder(object):
# class _KerasInitializer(tf.keras.initializers.Initializer):
# class KerasLayer(tf.keras.layers.Layer):
# class KerasMetricWrapper(tf.keras.metrics.Metric):
#   def __init__(self, callback):
#   def __call__(self):
#   def assign(self, y_true=None, y_pred=None):
#   def __init__(self, value):
#   def __call__(self, shape, dtype=None):
#   def get_config(self):
#   def __init__(self,
#                objective=None,
#                constraints=None,
#                placeholders=None,
#                name=None,
#                denominator_lower_bound=1e-3,
#                loss_creator=lagrangian_optimizer.create_lagrangian_loss,
#                **kwargs):
#   def _variable_fn(self, initial_value, **kwargs):
#   def loss(self, y_true, y_pred):
#   def get_config(self):
#   def __init__(self,
#                wrapped,
#                predictions=None,
#                labels=None,
#                from_logits=False,
#                name=None,
#                **kwargs):
#   def update_state(self, y_true, y_pred, **kwargs):
#   def reset_states(self):
#   def result(self):
# 
# Path: tensorflow_constrained_optimization/python/rates/operations.py
# def wrap_rate(penalty_tensor, constraint_tensor=None):
# def upper_bound(expressions):
# def lower_bound(expressions):


# Path: tensorflow_constrained_optimization/python/rates/keras_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 keras
from tensorflow_constrained_optimization.python.rates import operations

    self._last_method = "reset_states"

  def result(self):
    self._last_method = "result"
    return 0


# @run_all_tests_in_graph_and_eager_modes
class KerasTest(graph_and_eager_test_case.GraphAndEagerTestCase):
  """Tests for classes in keras.py."""

  def test_keras_placeholder(self):
    """Tests the `KerasPlaceholder` class."""
    y_pred_placeholder = keras.KerasPlaceholder(lambda y_true, y_pred: y_pred)
    y_true_placeholder = keras.KerasPlaceholder(lambda y_true, y_pred: y_true)

    y_pred_placeholder.assign(-2.0, -1.0)
    y_true_placeholder.assign(1.0, 2.0)
    self.assertEqual(-1.0, y_pred_placeholder())
    self.assertEqual(1.0, y_true_placeholder())

    y_pred_placeholder.assign()
    y_true_placeholder.assign()
    with self.assertRaises(RuntimeError):
      _ = y_pred_placeholder()
    with self.assertRaises(RuntimeError):
      _ = y_true_placeholder()

  def test_keras_layer(self):
    """Tests the `KerasLayer` class."""

    zero_placeholder = keras.KerasPlaceholder(