code: def test_different_y_shapes_with_class_weight(self):
      x = np.random.random((4, 2))
      y = np.array(
          [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],
          dtype="float32",
      )
      base_ds = tf.data.Dataset.from_tensor_slices((x, y)).batch(16)
      class_weight = {0: 0.1, 1: 0.2, 2: 0.3, 3: 0.4}
      adapter = tf_dataset_adapter.TFDatasetAdapter(
          base_ds, class_weight=class_weight
      )
      gen = adapter.get_numpy_iterator()
      for batch in gen:
          _, _, bw = batch
          self.assertAllClose(bw, [0.1, 0.2, 0.3, 0.4])
  
      y_sparse = np.array([0, 1, 2, 3], dtype="int64")
      base_ds = tf.data.Dataset.from_tensor_slices((x, y_sparse)).batch(
          16
      )
      adapter = tf_dataset_adapter.TFDatasetAdapter(
          base_ds, class_weight=class_weight
      )
      gen = adapter.get_numpy_iterator()
      for batch in gen:
          _, _, 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 8 for calling the TestTFDatasetAdapter obj's underlying member method code with example usage: obj.test_different_y_shapes_with_class_weight() without return types