code: def _test_class_weights(self, target_encoding="int"):
      x = np.random.random((4, 2))
      if target_encoding == "int":
          y = np.array([[0], [1], [2], [3]], dtype="int64")
      else:
          y = np.array(
              [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],
              dtype="float32",
          )
  
      class_weight = {
          0: 0.1,
          1: 0.2,
          2: 0.3,
          3: 0.4,
      }
      base_ds = tf.data.Dataset.from_tensor_slices((x, y)).batch(16)
      adapter = tf_dataset_adapter.TFDatasetAdapter(
          base_ds, class_weight=class_weight
      )
      gen = adapter.get_numpy_iterator()
      for batch in gen:
          self.assertEqual(len(batch), 3)
          _, _, bw = batch
          self.assertAllClose(bw, [0.1, 0.2, 0.3, 0.4])
  
file_path: keras/keras/trainers/data_adapters/tf_dataset_adapter_test.py
imports: from unittest import mock
  import numpy
  import tensorflow
  from keras import testing
  from keras.trainers.data_adapters import tf_dataset_adapter
label_desc: Use image node_id 2 for calling the TestTFDatasetAdapter obj's underlying member method code with example usage: obj._test_class_weights(target_encoding) without return types