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 state_dict(
      self, num_samples_yielded: int, num_workers: int, batch_size: int
  ) -> Dict[str, Any]:
      if _is_in_dataloader_worker():
          raise RuntimeError(
              "The method `state_dict` should only be called in the main process."
          )
  
      state = {
          "num_samples_yielded": num_samples_yielded,
          "num_workers": num_workers,
          "batch_size": batch_size,
          "current_epoch": self.current_epoch,
          "input_dir_path": self.input_dir.path,
          "input_dir_url": self.input_dir.url,
          "item_loader": self.item_loader.state_dict()
          if self.item_loader
          else None,
          "drop_last": self.drop_last,
          "seed": self.seed,
          "world_size": self.distributed_env.world_size,
          "shuffle": self.shuffle,
      }
  
      if self._state_dict:
          num_restarts = len(self._state_dict)
          return {**self._state_dict, f"{num_restarts}": state}
      return {"0": state}
  
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 9 for calling the StreamingDataset obj's underlying member method code with example usage: obj.state_dict(num_samples_yielded, num_workers, batch_size) and returns: dict, dict