code: def test_tf_data_compatibility(self):
      layer = layers.CategoryEncoding(
          num_tokens=4, output_mode="one_hot", dtype="int32"
      )
      input_data = np.array([3, 2, 0, 1])
      expected_output = np.array(
          [
              [0, 0, 0, 1],
              [0, 0, 1, 0],
              [1, 0, 0, 0],
              [0, 1, 0, 0],
          ]
      )
      ds = (
          tf_data.Dataset.from_tensor_slices(input_data)
          .batch(4)
          .map(layer)
      )
      for output in ds.take(1):
          output = output.numpy()
      self.assertAllClose(output, expected_output)
  
file_path: keras/keras/layers/preprocessing/category_encoding_test.py
imports: import numpy
  from tensorflow import data
  from keras import layers
  from keras import testing
label_desc: Use image node_id 7 for calling the CategoryEncodingTest obj's underlying member method code with example usage: obj.test_tf_data_compatibility() without return types