# Path: tensorflow_model_remediation/min_diff/losses/base_loss.py
# class MinDiffLoss(tf.keras.losses.Loss, abc.ABC):
#   def __init__(self,
#                membership_transform=None,
#                predictions_transform=None,
#                membership_kernel=None,
#                predictions_kernel=None,
#                name: Optional[str] = None,
#                enable_summary_histogram: Optional[bool] = True):
#   def __call__(self,
#                membership: types.TensorType,
#                predictions: types.TensorType,
#                sample_weight: Optional[types.TensorType] = None):
#   def _preprocess_inputs(
#       self,
#       membership: types.TensorType,
#       predictions: types.TensorType,
#       sample_weight: Optional[types.TensorType] = None
#   ) -> Tuple[types.TensorType, types.TensorType, types.TensorType]:
#   def _apply_kernels(
#       self, membership: types.TensorType, predictions: types.TensorType
#   ) -> Tuple[types.TensorType, types.TensorType]:
#   def call(self,
#            membership: types.TensorType,
#            predictions: types.TensorType,
#            sample_weight: Optional[types.TensorType] = None):
#   def _serialize_config(self, config):
#     def _serialize_value(key, value):
#   def get_config(self):
#   def _deserialize_config(cls, config):
#     def _deserialize_value(key, value):
#   def from_config(cls, config):
# def _validate_transform(transform: types.TensorTransformType,
#                         var_name: str) -> None:
# def _to_snake_case(name):
# 
# Path: tensorflow_model_remediation/min_diff/losses/kernels/base_kernel.py
# class MinDiffKernel(abc.ABC):
#   def __init__(self, tile_input: bool = True):
#   def __call__(self,
#                x: types.TensorType,
#                y: Optional[types.TensorType] = None) -> types.TensorType:
#   def call(self, x: types.TensorType, y: types.TensorType):
#   def get_config(self):
#   def from_config(cls, config):
# 
# Path: tensorflow_model_remediation/min_diff/losses/kernels/gaussian_kernel.py
# class GaussianKernel(base_kernel.MinDiffKernel):
#   def __init__(self, kernel_length: complex = 0.1, **kwargs):
#   def call(self, x: types.TensorType, y: types.TensorType) -> types.TensorType:
#   def get_config(self):
# 
# Path: tensorflow_model_remediation/min_diff/losses/kernels/laplacian_kernel.py
# _EPSILON = 1.0e-8
# class LaplacianKernel(base_kernel.MinDiffKernel):
#   def __init__(self, kernel_length: complex = 0.1, **kwargs):
#   def call(self, x: types.TensorType, y: types.TensorType) -> types.TensorType:
#   def get_config(self):


import tensorflow as tf
from tensorflow_model_remediation.min_diff.losses import base_loss
from tensorflow_model_remediation.min_diff.losses.kernels import base_kernel
from tensorflow_model_remediation.min_diff.losses.kernels import gaussian_kernel
from tensorflow_model_remediation.min_diff.losses.kernels import laplacian_kernel
    loss = CustomLoss()
    serialized_loss = tf.keras.utils.serialize_keras_object(loss)
    deserialized_loss = tf.keras.utils.deserialize_keras_object(serialized_loss)

    self.assertIsInstance(deserialized_loss, CustomLoss)
    self.assertIsNone(deserialized_loss.membership_transform)
    self.assertIsNone(deserialized_loss.predictions_transform)
    self.assertIsNone(deserialized_loss.membership_kernel)
    self.assertIsNone(deserialized_loss.predictions_kernel)
    self.assertEqual(deserialized_loss.name, loss.name)

  def testSerializationWithTransformsAndKernels(self):
    membership_fn = lambda x: x * 2.3  # Arbitrary operation.
    predictions_fn = lambda x: x * 5.1  # Arbitrary operation.

    loss = CustomLoss(
        membership_transform=membership_fn,
        membership_kernel='gaussian',
        predictions_transform=predictions_fn,
        predictions_kernel='laplacian')
    serialized_loss = tf.keras.utils.serialize_keras_object(loss)
    deserialized_loss = tf.keras.utils.deserialize_keras_object(serialized_loss)

    self.assertIsInstance(deserialized_loss, CustomLoss)
    val = 7  # Arbitrary value.
    self.assertEqual(
        deserialized_loss.membership_transform(val), membership_fn(val))
    self.assertEqual(
        deserialized_loss.predictions_transform(val), predictions_fn(val))
    self.assertIsInstance(deserialized_loss.membership_kernel,

# Path: tensorflow_model_remediation/min_diff/losses/base_loss.py
# class MinDiffLoss(tf.keras.losses.Loss, abc.ABC):
#   def __init__(self,
#                membership_transform=None,
#                predictions_transform=None,
#                membership_kernel=None,
#                predictions_kernel=None,
#                name: Optional[str] = None,
#                enable_summary_histogram: Optional[bool] = True):
#   def __call__(self,
#                membership: types.TensorType,
#                predictions: types.TensorType,
#                sample_weight: Optional[types.TensorType] = None):
#   def _preprocess_inputs(
#       self,
#       membership: types.TensorType,
#       predictions: types.TensorType,
#       sample_weight: Optional[types.TensorType] = None
#   ) -> Tuple[types.TensorType, types.TensorType, types.TensorType]:
#   def _apply_kernels(
#       self, membership: types.TensorType, predictions: types.TensorType
#   ) -> Tuple[types.TensorType, types.TensorType]:
#   def call(self,
#            membership: types.TensorType,
#            predictions: types.TensorType,
#            sample_weight: Optional[types.TensorType] = None):
#   def _serialize_config(self, config):
#     def _serialize_value(key, value):
#   def get_config(self):
#   def _deserialize_config(cls, config):
#     def _deserialize_value(key, value):
#   def from_config(cls, config):
# def _validate_transform(transform: types.TensorTransformType,
#                         var_name: str) -> None:
# def _to_snake_case(name):
# 
# Path: tensorflow_model_remediation/min_diff/losses/kernels/base_kernel.py
# class MinDiffKernel(abc.ABC):
#   def __init__(self, tile_input: bool = True):
#   def __call__(self,
#                x: types.TensorType,
#                y: Optional[types.TensorType] = None) -> types.TensorType:
#   def call(self, x: types.TensorType, y: types.TensorType):
#   def get_config(self):
#   def from_config(cls, config):
# 
# Path: tensorflow_model_remediation/min_diff/losses/kernels/gaussian_kernel.py
# class GaussianKernel(base_kernel.MinDiffKernel):
#   def __init__(self, kernel_length: complex = 0.1, **kwargs):
#   def call(self, x: types.TensorType, y: types.TensorType) -> types.TensorType:
#   def get_config(self):
# 
# Path: tensorflow_model_remediation/min_diff/losses/kernels/laplacian_kernel.py
# _EPSILON = 1.0e-8
# class LaplacianKernel(base_kernel.MinDiffKernel):
#   def __init__(self, kernel_length: complex = 0.1, **kwargs):
#   def call(self, x: types.TensorType, y: types.TensorType) -> types.TensorType:
#   def get_config(self):


# Path: tensorflow_model_remediation/min_diff/losses/base_loss_test.py
import tensorflow as tf
from tensorflow_model_remediation.min_diff.losses import base_loss
from tensorflow_model_remediation.min_diff.losses.kernels import base_kernel
from tensorflow_model_remediation.min_diff.losses.kernels import gaussian_kernel
from tensorflow_model_remediation.min_diff.losses.kernels import laplacian_kernel

    loss = CustomLoss()
    serialized_loss = tf.keras.utils.serialize_keras_object(loss)
    deserialized_loss = tf.keras.utils.deserialize_keras_object(serialized_loss)

    self.assertIsInstance(deserialized_loss, CustomLoss)
    self.assertIsNone(deserialized_loss.membership_transform)
    self.assertIsNone(deserialized_loss.predictions_transform)
    self.assertIsNone(deserialized_loss.membership_kernel)
    self.assertIsNone(deserialized_loss.predictions_kernel)
    self.assertEqual(deserialized_loss.name, loss.name)

  def testSerializationWithTransformsAndKernels(self):
    membership_fn = lambda x: x * 2.3  # Arbitrary operation.
    predictions_fn = lambda x: x * 5.1  # Arbitrary operation.

    loss = CustomLoss(
        membership_transform=membership_fn,
        membership_kernel='gaussian',
        predictions_transform=predictions_fn,
        predictions_kernel='laplacian')
    serialized_loss = tf.keras.utils.serialize_keras_object(loss)
    deserialized_loss = tf.keras.utils.deserialize_keras_object(serialized_loss)

    self.assertIsInstance(deserialized_loss, CustomLoss)
    val = 7  # Arbitrary value.
    self.assertEqual(
        deserialized_loss.membership_transform(val), membership_fn(val))
    self.assertEqual(
        deserialized_loss.predictions_transform(val), predictions_fn(val))
    self.assertIsInstance(deserialized_loss.membership_kernel,

                          gaussian_kernel.GaussianKernel)