class_docstr: The streaming dataset can be used once your data have been optimised using the DatasetOptimiser class.
class_docstr_tok: ["The","streaming","dataset","can","be","used","once","your","data","have","been","optimised","using","the","DatasetOptimiser","class","."]
code: def __next__(self) -> Any:
      # Prevent to create more batch on a given process
      if self.global_index >= len(self):
          self.current_epoch += 1
          raise StopIteration
  
      # Lazily re-populate the interval to reduce memory usage.
      if len(self.current_indexes) == 0:
          if self.chunk_index == self.num_chunks:
              self.current_epoch += 1
              raise StopIteration
  
          # reset index
          self.index = 0
  
          interval = self.worker_intervals[self.chunk_index]
          current_indexes = np.arange(interval[0], interval[1])
  
          assert self.shuffler is not None
          assert self.num_chunks is not None
          self.current_indexes = self.shuffler(
              current_indexes,
              self.num_chunks,
              self.current_epoch,
              self.chunk_index,
          )
  
          self.chunk_index += 1
  
      # Get the first index
      index = self.current_indexes.pop(0)
  
      # Call the `__getitem__` method.
      data = self.__getitem__(
          ChunkedIndex(
              index=index,
              chunk_index=self.worker_chunks[self.chunk_index - 1],
              # We provide the chunks indexes only one the first
              chunk_indexes=None
              if self.has_triggered_download
              else self.worker_chunks,
              is_last_index=(self.chunk_index - 1)
              == len(self.worker_intervals)
              and len(self.current_indexes) == 1,
          )
      )
  
      self.has_triggered_download = True
      self.global_index += 1
      self.index += 1
  
      return data
  
imports: import hashlib
  import os
  from dataclasses import dataclass
  from time import time
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  from torch.utils.data import IterableDataset, get_worker_info
  from lightning.data.streaming import Cache
  from lightning.data.streaming.constants import _DEFAULT_CACHE_DIR, _INDEX_FILENAME, _LIGHTNING_CLOUD_LATEST
  from lightning.data.streaming.item_loader import BaseItemLoader
  from lightning.data.streaming.sampler import ChunkedIndex
  from lightning.data.streaming.serializers import Serializer
  from lightning.data.streaming.shuffle import FullShuffle, NoShuffle, Shuffle
  from lightning.data.utilities.env import Environment, _DistributedEnv, _WorkerEnv
label_desc: Use image node_id 8 for calling the StreamingDataset obj's underlying member method code with example usage: obj.__next__() and returns: data