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: Returns the iterator to use for `iter_batches`.
  
  Returns:
      A tuple. The first item of the tuple is an iterator over pairs of Block
      object references and their corresponding metadata. The second item of the
      tuple is a DatasetStats object used for recording stats during iteration.
      The third item is a boolean indicating if the blocks can be safely cleared
      after use.
docstr_tok: ["Returns","the","iterator","to","use","for","`","iter_batches","`",".","Returns",":","A","tuple",".","The","first","item","of","the","tuple","is","an","iterator","over","pairs","of","Block","object","references","and","their","corresponding","metadata",".","The","second","item","of","the","tuple","is","a","DatasetStats","object","used","for","recording","stats","during","iteration",".","The","third","item","is","a","boolean","indicating","if","the","blocks","can","be","safely","cleared","after","use","."]
code: def _to_block_iterator(
      self,
  ) -> Tuple[
      Iterator[Tuple[ObjectRef[Block], BlockMetadata]],
      Optional[DatasetStats],
      bool,
  ]:
      """Returns the iterator to use for `iter_batches`.
  
      Returns:
          A tuple. The first item of the tuple is an iterator over pairs of Block
          object references and their corresponding metadata. The second item of the
          tuple is a DatasetStats object used for recording stats during iteration.
          The third item is a boolean indicating if the blocks can be safely cleared
          after use.
      """
      raise NotImplementedError
  
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 1 for calling the DataIterator obj's underlying member method code with example usage: obj._to_block_iterator() without return types