class_docstr: An iterator for reading records from a :class:`~Dataset`.
  
  For Datasets, each iteration call represents a complete read of all items in the
  Dataset.
  
  If using Ray Train, each trainer actor should get its own iterator by calling
  :meth:`ray.train.get_dataset_shard("train")
  <ray.train.get_dataset_shard>`.
  
  Examples:
      >>> import ray
      >>> ds = ray.data.range(5)
      >>> ds
      Dataset(num_blocks=..., num_rows=5, schema={id: int64})
      >>> ds.iterator()
      DataIterator(Dataset(num_blocks=..., num_rows=5, schema={id: int64}))
class_docstr_tok: ["An","iterator","for","reading","records","from","a",":","class",":","`","~Dataset","`",".","For","Datasets",",","each","iteration","call","represents","a","complete","read","of","all","items","in","the","Dataset",".","If","using","Ray","Train",",","each","trainer","actor","should","get","its","own","iterator","by","calling",":","meth",":","`","ray.train.get_dataset_shard","(","``","train","''",")","<","ray.train.get_dataset_shard",">","`",".","Examples",":",">",">",">","import","ray",">",">",">","ds","=","ray.data.range","(","5",")",">",">",">","ds","Dataset","(","num_blocks=","...",",","num_rows=5",",","schema=","{","id",":","int64","}",")",">",">",">","ds.iterator","(",")","DataIterator","(","Dataset","(","num_blocks=","...",",","num_rows=5",",","schema=","{","id",":","int64","}",")",")"]
docstr: Return a batched iterable of TensorFlow Tensors over the dataset.
  
  This iterable will yield single-tensor batches of the underlying dataset
  consists of a single column; otherwise, it will yield a dictionary of
  column-tensors.
  
  .. tip::
      If you don't need the additional flexibility provided by this method,
      consider using :meth:`~ray.data.Dataset.to_tf` instead. It's easier
      to use.
  
  Examples:
      >>> import ray
      >>> for batch in ray.data.range( # doctest: +SKIP
      ...     12,
      ... ).iter_tf_batches(batch_size=4):
      ...     print(batch.shape) # doctest: +SKIP
      (4, 1)
      (4, 1)
      (4, 1)
  
  Time complexity: O(1)
  
  Args:
      prefetch_batches: The number of batches to fetch ahead of the current batch
          to fetch. If set to greater than 0, a separate threadpool will be used
          to fetch the objects to the local node, format the batches, and apply
          the collate_fn. Defaults to 1.
      batch_size: The number of rows in each batch, or None to use entire blocks
          as batches (blocks may contain different number of rows).
          The final batch may include fewer than ``batch_size`` rows if
          ``drop_last`` is ``False``. Defaults to 256.
      dtypes: The TensorFlow dtype(s) for the created tensor(s); if None, the
          dtype will be inferred from the tensor data.
      drop_last: Whether to drop the last batch if it's incomplete.
      local_shuffle_buffer_size: If non-None, the data will be randomly shuffled
          using a local in-memory shuffle buffer, and this value will serve as the
          minimum number of rows that must be in the local in-memory shuffle
          buffer in order to yield a batch. When there are no more rows to add to
          the buffer, the remaining rows in the buffer will be drained. This
          buffer size must be greater than or equal to ``batch_size``, and
          therefore ``batch_size`` must also be specified when using local
          shuffling.
      local_shuffle_seed: The seed to use for the local random shuffle.
  
  Returns:
      An iterator over TensorFlow Tensor batches.
docstr_tok: ["Return","a","batched","iterable","of","TensorFlow","Tensors","over","the","dataset",".","This","iterable","will","yield","single-tensor","batches","of","the","underlying","dataset","consists","of","a","single","column",";","otherwise",",","it","will","yield","a","dictionary","of","column-tensors",".","..","tip",":",":","If","you","do","n't","need","the","additional","flexibility","provided","by","this","method",",","consider","using",":","meth",":","`","~ray.data.Dataset.to_tf","`","instead",".","It","'s","easier","to","use",".","Examples",":",">",">",">","import","ray",">",">",">","for","batch","in","ray.data.range","(","#","doctest",":","+SKIP","...","12",",","...",")",".iter_tf_batches","(","batch_size=4",")",":","...","print","(","batch.shape",")","#","doctest",":","+SKIP","(","4",",","1",")","(","4",",","1",")","(","4",",","1",")","Time","complexity",":","O","(","1",")","Args",":","prefetch_batches",":","The","number","of","batches","to","fetch","ahead","of","the","current","batch","to","fetch",".","If","set","to","greater","than","0",",","a","separate","threadpool","will","be","used","to","fetch","the","objects","to","the","local","node",",","format","the","batches",",","and","apply","the","collate_fn",".","Defaults","to","1.","batch_size",":","The","number","of","rows","in","each","batch",",","or","None","to","use","entire","blocks","as","batches","(","blocks","may","contain","different","number","of","rows",")",".","The","final","batch","may","include","fewer","than","``","batch_size","``","rows","if","``","drop_last","``","is","``","False","``",".","Defaults","to","256.","dtypes",":","The","TensorFlow","dtype","(","s",")","for","the","created","tensor","(","s",")",";","if","None",",","the","dtype","will","be","inferred","from","the","tensor","data",".","drop_last",":","Whether","to","drop","the","last","batch","if","it","'s","incomplete",".","local_shuffle_buffer_size",":","If","non-None",",","the","data","will","be","randomly","shuffled","using","a","local","in-memory","shuffle","buffer",",","and","this","value","will","serve","as","the","minimum","number","of","rows","that","must","be","in","the","local","in-memory","shuffle","buffer","in","order","to","yield","a","batch",".","When","there","are","no","more","rows","to","add","to","the","buffer",",","the","remaining","rows","in","the","buffer","will","be","drained",".","This","buffer","size","must","be","greater","than","or","equal","to","``","batch_size","``",",","and","therefore","``","batch_size","``","must","also","be","specified","when","using","local","shuffling",".","local_shuffle_seed",":","The","seed","to","use","for","the","local","random","shuffle",".","Returns",":","An","iterator","over","TensorFlow","Tensor","batches","."]
code: def iter_tf_batches(
      self,
      *,
      prefetch_batches: int = 1,
      batch_size: Optional[int] = 256,
      dtypes: Optional[
          Union["tf.dtypes.DType", Dict[str, "tf.dtypes.DType"]]
      ] = None,
      drop_last: bool = False,
      local_shuffle_buffer_size: Optional[int] = None,
      local_shuffle_seed: Optional[int] = None,
      # Deprecated.
      prefetch_blocks: int = 0,
  ) -> Iterable["TensorFlowTensorBatchType"]:
      """Return a batched iterable of TensorFlow Tensors over the dataset.
  
      This iterable will yield single-tensor batches of the underlying dataset
      consists of a single column; otherwise, it will yield a dictionary of
      column-tensors.
  
      .. tip::
          If you don't need the additional flexibility provided by this method,
          consider using :meth:`~ray.data.Dataset.to_tf` instead. It's easier
          to use.
  
      Examples:
          >>> import ray
          >>> for batch in ray.data.range( # doctest: +SKIP
          ...     12,
          ... ).iter_tf_batches(batch_size=4):
          ...     print(batch.shape) # doctest: +SKIP
          (4, 1)
          (4, 1)
          (4, 1)
  
      Time complexity: O(1)
  
      Args:
          prefetch_batches: The number of batches to fetch ahead of the current batch
              to fetch. If set to greater than 0, a separate threadpool will be used
              to fetch the objects to the local node, format the batches, and apply
              the collate_fn. Defaults to 1.
          batch_size: The number of rows in each batch, or None to use entire blocks
              as batches (blocks may contain different number of rows).
              The final batch may include fewer than ``batch_size`` rows if
              ``drop_last`` is ``False``. Defaults to 256.
          dtypes: The TensorFlow dtype(s) for the created tensor(s); if None, the
              dtype will be inferred from the tensor data.
          drop_last: Whether to drop the last batch if it's incomplete.
          local_shuffle_buffer_size: If non-None, the data will be randomly shuffled
              using a local in-memory shuffle buffer, and this value will serve as the
              minimum number of rows that must be in the local in-memory shuffle
              buffer in order to yield a batch. When there are no more rows to add to
              the buffer, the remaining rows in the buffer will be drained. This
              buffer size must be greater than or equal to ``batch_size``, and
              therefore ``batch_size`` must also be specified when using local
              shuffling.
          local_shuffle_seed: The seed to use for the local random shuffle.
  
      Returns:
          An iterator over TensorFlow Tensor batches.
      """
      from ray.air._internal.tensorflow_utils import (
          convert_ndarray_batch_to_tf_tensor_batch,
      )
  
      batch_iterable = self.iter_batches(
          prefetch_batches=prefetch_batches,
          prefetch_blocks=prefetch_blocks,
          batch_size=batch_size,
          drop_last=drop_last,
          local_shuffle_buffer_size=local_shuffle_buffer_size,
          local_shuffle_seed=local_shuffle_seed,
      )
      mapped_iterable = map(
          lambda batch: convert_ndarray_batch_to_tf_tensor_batch(
              batch, dtypes=dtypes
          ),
          batch_iterable,
      )
  
      return mapped_iterable
  
imports: import abc
  import time
  from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, TypeVar, Union
  import numpy
  from ray.data._internal.block_batching.iter_batches import iter_batches
  from ray.data._internal.stats import DatasetStats, StatsManager
  from ray.data.block import Block, BlockAccessor, BlockMetadata, DataBatch, _apply_strict_mode_batch_format
  from ray.types import ObjectRef
  from ray.util.annotations import PublicAPI
label_desc: Use image node_id 8 for calling the DataIterator obj's underlying member method code with example usage: obj.iter_tf_batches() and returns: mapped_iterable