# 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/kernel_utils.py
# _STRING_TO_KERNEL_DICT = {}
# def _register_kernel_names(kernel_class, names):
# def _get_kernel(kernel: Union[base_kernel.MinDiffKernel, str],
#                 kernel_var_name: str = 'kernel'):
# 
# 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.kernels import base_kernel
from tensorflow_model_remediation.min_diff.losses.kernels import gaussian_kernel
from tensorflow_model_remediation.min_diff.losses.kernels import kernel_utils as utils
from tensorflow_model_remediation.min_diff.losses.kernels import laplacian_kernel
    self.assertIsInstance(kernel, laplacian_kernel.LaplacianKernel)
    kernel = utils._get_kernel('laplacian')
    self.assertIsInstance(kernel, laplacian_kernel.LaplacianKernel)
    kernel = utils._get_kernel('laplacian_kernel')
    self.assertIsInstance(kernel, laplacian_kernel.LaplacianKernel)
    kernel = utils._get_kernel(laplacian_kernel.LaplacianKernel())
    self.assertIsInstance(kernel, laplacian_kernel.LaplacianKernel)
    kernel_length = 3
    kernel = utils._get_kernel(laplacian_kernel.LaplacianKernel(kernel_length))
    self.assertIsInstance(kernel, laplacian_kernel.LaplacianKernel)
    self.assertEqual(kernel.kernel_length, kernel_length)

  def testForCustomKernel(self):

    class CustomKernel(base_kernel.MinDiffKernel):

      def call(self, x, y):
        pass

    kernel = CustomKernel()
    kernel_output = utils._get_kernel(kernel)
    self.assertIs(kernel_output, kernel)

  def testGetKernelRaisesErrors(self):
    with self.assertRaisesRegex(
        TypeError, 'custom_name.*must be.*MinDiffKernel.*string.*4.*int'):
      utils._get_kernel(4, 'custom_name')

    with self.assertRaisesRegex(
        ValueError, 'custom_name.*must be.*supported values.*bad_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/kernel_utils.py
# _STRING_TO_KERNEL_DICT = {}
# def _register_kernel_names(kernel_class, names):
# def _get_kernel(kernel: Union[base_kernel.MinDiffKernel, str],
#                 kernel_var_name: str = 'kernel'):
# 
# 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/kernels/kernel_utils_test.py
import tensorflow as tf
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 kernel_utils as utils
from tensorflow_model_remediation.min_diff.losses.kernels import laplacian_kernel

    self.assertIsInstance(kernel, laplacian_kernel.LaplacianKernel)
    kernel = utils._get_kernel('laplacian')
    self.assertIsInstance(kernel, laplacian_kernel.LaplacianKernel)
    kernel = utils._get_kernel('laplacian_kernel')
    self.assertIsInstance(kernel, laplacian_kernel.LaplacianKernel)
    kernel = utils._get_kernel(laplacian_kernel.LaplacianKernel())
    self.assertIsInstance(kernel, laplacian_kernel.LaplacianKernel)
    kernel_length = 3
    kernel = utils._get_kernel(laplacian_kernel.LaplacianKernel(kernel_length))
    self.assertIsInstance(kernel, laplacian_kernel.LaplacianKernel)
    self.assertEqual(kernel.kernel_length, kernel_length)

  def testForCustomKernel(self):

    class CustomKernel(base_kernel.MinDiffKernel):

      def call(self, x, y):
        pass

    kernel = CustomKernel()
    kernel_output = utils._get_kernel(kernel)
    self.assertIs(kernel_output, kernel)

  def testGetKernelRaisesErrors(self):
    with self.assertRaisesRegex(
        TypeError, 'custom_name.*must be.*MinDiffKernel.*string.*4.*int'):
      utils._get_kernel(4, 'custom_name')

    with self.assertRaisesRegex(
        ValueError, 'custom_name.*must be.*supported values.*bad_name'):

      utils._get_kernel('bad_name', 'custom_name')