code: def test_num_batches(self):
      dataset = tf.data.Dataset.range(42)
      cardinality = int(dataset.cardinality())
      self.assertEqual(cardinality, 42)
      adapter = tf_dataset_adapter.TFDatasetAdapter(dataset)
      self.assertEqual(adapter.num_batches, 42)
  
      # Test for Infiniate Cardinality
      dataset = tf.data.Dataset.range(42)
      dataset = dataset.repeat()
      cardinality = int(dataset.cardinality())
      self.assertEqual(cardinality, tf.data.INFINITE_CARDINALITY)
      adapter = tf_dataset_adapter.TFDatasetAdapter(dataset)
      self.assertIsNone(adapter.num_batches)
  
      # Test for Unknown Cardinality
      dataset = dataset.filter(lambda x: True)
      cardinality = int(dataset.cardinality())
      self.assertEqual(cardinality, tf.data.UNKNOWN_CARDINALITY)
      adapter = tf_dataset_adapter.TFDatasetAdapter(dataset)
      self.assertIsNone(adapter.num_batches)
  
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 5 for calling the TestTFDatasetAdapter obj's underlying member method code with example usage: obj.test_num_batches() without return types