class_docstr: Adapter that handles `tf.data.Dataset`.
class_docstr_tok: ["Adapter","that","handles","`","tf.data.Dataset","`","."]
docstr: Iniitialize the TFDatasetAdapter.
  
  Args:
      dataset: The input `tf.data.Dataset` instance.
      class_weight: A map where the keys are integer class ids and values
          are the class weights, e.g. `{0: 0.2, 1: 0.6, 2: 0.3}`.
      distribution: A `keras.distribution.Distribution` instance. Used to
          shard the input dataset into per worker/process dataset
          instance.
docstr_tok: ["Iniitialize","the","TFDatasetAdapter",".","Args",":","dataset",":","The","input","`","tf.data.Dataset","`","instance",".","class_weight",":","A","map","where","the","keys","are","integer","class","ids","and","values","are","the","class","weights",",","e.g",".","`","{","0",":","0.2",",","1",":","0.6",",","2",":","0.3","}","`",".","distribution",":","A","`","keras.distribution.Distribution","`","instance",".","Used","to","shard","the","input","dataset","into","per","worker\/process","dataset","instance","."]
code: def __init__(self, dataset, class_weight=None, distribution=None):
      """Iniitialize the TFDatasetAdapter.
  
      Args:
          dataset: The input `tf.data.Dataset` instance.
          class_weight: A map where the keys are integer class ids and values
              are the class weights, e.g. `{0: 0.2, 1: 0.6, 2: 0.3}`.
          distribution: A `keras.distribution.Distribution` instance. Used to
              shard the input dataset into per worker/process dataset
              instance.
      """
      from keras.utils.module_utils import tensorflow as tf
  
      if not isinstance(
          dataset, (tf.data.Dataset, tf.distribute.DistributedDataset)
      ):
          raise ValueError(
              "Expected argument `dataset` to be a tf.data.Dataset. "
              f"Received: {dataset}"
          )
      if class_weight is not None:
          dataset = dataset.map(
              make_class_weight_map_fn(class_weight)
          ).prefetch(tf.data.AUTOTUNE)
      if distribution is not None:
          dataset = distribution.distribute_dataset(dataset)
      self._dataset = dataset
  
file_path: keras/keras/trainers/data_adapters/tf_dataset_adapter.py
imports: import numpy
  import tree
  from keras.trainers.data_adapters import data_adapter_utils
  from keras.trainers.data_adapters.data_adapter import DataAdapter
label_desc: Use image node_id 1 to create a new TFDatasetAdapter object from inherited base classes: DataAdapter with example: obj = TFDatasetAdapter(dataset, class_weight, distribution)