code: def testCategoricalDistance(self):
      base_kernel = exponentiated_quadratic.ExponentiatedQuadratic()
      isd = np.ones([2], dtype=np.float32)
      kernel = fswc.FeatureScaledWithCategorical(
          base_kernel,
          inverse_scale_diag=fswc.ContinuousAndCategoricalValues(
              isd, isd
          ),
          validate_args=True,
      )
  
      # Sample some non-overlapping "categorical" data, represented by integers.
      x1_cat = np.random.randint(5, size=(3, 2))
      x2_cat = np.random.randint(6, 10, size=(2, 3, 2))
  
      x1_cont = np.ones(x1_cat.shape).astype(np.float32)
      x2_cont = np.ones(x2_cat.shape).astype(np.float32)
  
      x1 = fswc.ContinuousAndCategoricalValues(x1_cont, x1_cat)
      x2 = fswc.ContinuousAndCategoricalValues(x2_cont, x2_cat)
  
      kern_mat = self.evaluate(kernel.matrix(x1, x2))
      self.assertAllClose(
          kern_mat, np.exp(-1.0) * np.ones_like(kern_mat)
      )
  
      # Make some of the categorical features equal.
      x2_cat[0, 1, 0] = x1_cat[2, 0]
      x2_cat[1, 2, 1] = x1_cat[0, 1]
      x2_cat[1, 1, :] = x1_cat[1, :]
      x1a = fswc.ContinuousAndCategoricalValues(x1_cont, x1_cat)
      x2a = fswc.ContinuousAndCategoricalValues(x2_cont, x2_cat)
  
      # Assert that the pairs with equal categorical feature are as expected.
      kern_mat = self.evaluate(kernel.matrix(x1a, x2a))
      self.assertAllClose(kern_mat[0, 2, 1], np.exp(-0.5))
      self.assertAllClose(kern_mat[1, 0, 2], np.exp(-0.5))
      self.assertAllClose(kern_mat[1, 1, 1], 1.0)
  
file_path: probability/tensorflow_probability/python/experimental/psd_kernels/feature_scaled_with_categorical_test.py
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.experimental.psd_kernels import feature_scaled_with_categorical
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math.psd_kernels import exponentiated_quadratic
  from tensorflow_probability.python.math.psd_kernels import feature_scaled
  from tensorflow_probability.python.math.psd_kernels import matern
label_desc: Use image node_id 2 for calling the FeatureScaledWithCategoricalTest obj's underlying member method code with example usage: obj.testCategoricalDistance() without return types