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


import tensorflow as tf
from tensorflow_model_remediation.min_diff.losses.kernels import gaussian_kernel

      # Vector where all elements are equal should result in matrix of all 1s.
      for val in [0.2, 1.0, 2.79]:  # Arbitrary values.
        kernel_val = gaussian_kernel_fn(tf.constant([[val, val], [val, val]]))
        self.assertAllClose(kernel_val, tf.ones((2, 2)))

      # If tensors are equal, it should be the same as single tensor.
      # Note that we pick d < 0.1 so that the result is not the identity.
      tensor = tf.constant([[1.0], [1.01]])
      single_kernel_val = gaussian_kernel_fn(tensor)
      # Assert that the result is nontrivial (not the identity).
      self.assertNotAllClose(tf.eye(2), single_kernel_val)

      double_kernel_val = gaussian_kernel_fn(tensor, tensor)
      self.assertAllClose(single_kernel_val, double_kernel_val)

      # If the delta is the same, then the result should be the same.
      # Note that we pick d < 0.1 so that the result is not the identity.
      tensor1 = tf.constant([[1.0], [2.003]])
      tensor2 = tf.constant([[1.0], [5.503]])
      delta = tf.constant([[0.0], [0.01]])
      kernel_val1 = gaussian_kernel_fn(tensor1, tensor1 + delta)
      # Assert that the result is nontrivial (not the identity).
      self.assertNotAllClose(tf.eye(2), kernel_val1)

      kernel_val2 = gaussian_kernel_fn(tensor2, tensor2 + delta)
      self.assertAllClose(kernel_val1, kernel_val2)

  def testGetAndFromConfig(self):
    kernel_length = 5  # Arbitrary value.

# 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/gaussian_kernel_test.py
import tensorflow as tf
from tensorflow_model_remediation.min_diff.losses.kernels import gaussian_kernel


      # Vector where all elements are equal should result in matrix of all 1s.
      for val in [0.2, 1.0, 2.79]:  # Arbitrary values.
        kernel_val = gaussian_kernel_fn(tf.constant([[val, val], [val, val]]))
        self.assertAllClose(kernel_val, tf.ones((2, 2)))

      # If tensors are equal, it should be the same as single tensor.
      # Note that we pick d < 0.1 so that the result is not the identity.
      tensor = tf.constant([[1.0], [1.01]])
      single_kernel_val = gaussian_kernel_fn(tensor)
      # Assert that the result is nontrivial (not the identity).
      self.assertNotAllClose(tf.eye(2), single_kernel_val)

      double_kernel_val = gaussian_kernel_fn(tensor, tensor)
      self.assertAllClose(single_kernel_val, double_kernel_val)

      # If the delta is the same, then the result should be the same.
      # Note that we pick d < 0.1 so that the result is not the identity.
      tensor1 = tf.constant([[1.0], [2.003]])
      tensor2 = tf.constant([[1.0], [5.503]])
      delta = tf.constant([[0.0], [0.01]])
      kernel_val1 = gaussian_kernel_fn(tensor1, tensor1 + delta)
      # Assert that the result is nontrivial (not the identity).
      self.assertNotAllClose(tf.eye(2), kernel_val1)

      kernel_val2 = gaussian_kernel_fn(tensor2, tensor2 + delta)
      self.assertAllClose(kernel_val1, kernel_val2)

  def testGetAndFromConfig(self):
    kernel_length = 5  # Arbitrary value.

    kernel = gaussian_kernel.GaussianKernel(kernel_length)