class_docstr: This class is used to control batch fetching flow.
  
  Args:
      prefetch_batches: Number of batches to pre-fetch. Pre-fetching at least 1 batch is necessary to properly track
          whether a batch is the last one (available with :attr:`self.done`) when the length is not available. The
          value of this argument is ignored when the length is available.
class_docstr_tok: ["This","class","is","used","to","control","batch","fetching","flow",".","Args",":","prefetch_batches",":","Number","of","batches","to","pre-fetch",".","Pre-fetching","at","least","1","batch","is","necessary","to","properly","track","whether","a","batch","is","the","last","one","(","available","with",":","attr",":","`","self.done","`",")","when","the","length","is","not","available",".","The","value","of","this","argument","is","ignored","when","the","length","is","available","."]
code: def __next__(self) -> _ITERATOR_RETURN:
      if self.batches:
          # there are pre-fetched batches already from a previous `prefetching` call.
          # consume one
          batch = self.batches.pop(0)
          try:
              # refill the consumed batch
              self.batches.append(super().__next__())
          except StopIteration:
              # no more batches to fetch. we are done only if all pre-fetched batches were returned
              self.done = not self.batches
      elif not self.done:
          # this will run only when no pre-fetching was done.
          batch = super().__next__()
      else:
          # the iterator is empty
          raise StopIteration
      return batch
  
imports: from typing import Any, Iterator, List, Optional
  from typing_extensions import override
  from lightning.fabric.utilities.data import sized_len
  from lightning.pytorch.utilities.combined_loader import _ITERATOR_RETURN, CombinedLoader
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
label_desc: Use image node_id 3 for calling the _PrefetchDataFetcher obj's underlying member method code with example usage: obj.__next__() and returns: batch