code: def test_adapt_flow(self):
      adapt_data = [1, 1, 1, 2, 2, 3]
      single_sample_input_data = [1, 2, 4]
      batch_input_data = [[1, 2, 4], [2, 3, 5]]
  
      # int mode
      layer = layers.IntegerLookup(
          output_mode="int",
      )
      layer.adapt(adapt_data)
      output = layer(single_sample_input_data)
      self.assertTrue(backend.is_tensor(output))
      self.assertAllClose(output, np.array([1, 2, 0]))
      output = layer(batch_input_data)
      self.assertTrue(backend.is_tensor(output))
      self.assertAllClose(output, np.array([[1, 2, 0], [2, 3, 0]]))
  
      # one_hot mode
      layer = layers.IntegerLookup(
          output_mode="one_hot",
      )
      layer.adapt(adapt_data)
      output = layer(single_sample_input_data)
      self.assertTrue(backend.is_tensor(output))
      self.assertAllClose(
          output, np.array([[0, 1, 0, 0], [0, 0, 1, 0], [1, 0, 0, 0]])
      )
  
      # multi_hot mode
      layer = layers.IntegerLookup(
          output_mode="multi_hot",
      )
      layer.adapt(adapt_data)
      output = layer(single_sample_input_data)
      self.assertTrue(backend.is_tensor(output))
      self.assertAllClose(output, np.array([1, 1, 1, 0]))
  
      # tf_idf mode
      layer = layers.IntegerLookup(
          output_mode="tf_idf",
      )
      layer.adapt(adapt_data)
      output = layer(single_sample_input_data)
      self.assertTrue(backend.is_tensor(output))
      self.assertAllClose(
          output, np.array([1.133732, 0.916291, 1.098612, 0.0])
      )
  
      # count mode
      layer = layers.IntegerLookup(
          output_mode="count",
      )
      layer.adapt(adapt_data)
      output = layer([1, 2, 3, 4, 1, 2, 1])
      self.assertTrue(backend.is_tensor(output))
      self.assertAllClose(output, np.array([1, 3, 2, 1]))
  
file_path: keras/keras/layers/preprocessing/integer_lookup_test.py
imports: import numpy
  from tensorflow import data
  from keras import backend
  from keras import layers
  from keras import testing
label_desc: Use image node_id 2 for calling the IntegerLookupTest obj's underlying member method code with example usage: obj.test_adapt_flow() without return types