code: def __iter_from_shuffled_chunks(
      self,
      shuffled_indexes: List[int],
      shuffled_chunk_intervals: List[List[int]],
  ) -> Iterator[List[Union[int, ChunkedIndex]]]:
      chunks_per_workers: List[List[int]] = [
          [] for _ in range(self._num_workers)
      ]
      for i, chunk_index in enumerate(shuffled_indexes):
          chunks_per_workers[i % self._num_workers].append(chunk_index)
  
      indices_per_workers: List[List[ChunkedIndex]] = [
          [] for _ in range(self._num_workers)
      ]
  
      for i, (chunk_index, chunk_interval) in enumerate(
          zip(shuffled_indexes, shuffled_chunk_intervals)
      ):
          worker_id = i % self._num_workers
          interval_indices = np.arange(
              chunk_interval[0], chunk_interval[1]
          )
          shuffled_interval_indices = np.random.permutation(
              interval_indices
          ).tolist()
          is_empty = len(indices_per_workers[worker_id]) == 0
          indices_per_workers[worker_id].extend(
              [
                  ChunkedIndex(
                      index,
                      chunk_index,
                      chunk_indexes=chunks_per_workers[worker_id]
                      if j == 0 and is_empty
                      else None,
                  )
                  for j, index in enumerate(shuffled_interval_indices)
              ]
          )
  
      indices_per_workers_splitted = [
          self._chunk_list(indices, self._batch_size)
          for indices in indices_per_workers
      ]
  
      yield from self.__iter_indices_per_workers__(
          indices_per_workers_splitted
      )
  
file_path: pytorch-lightning/src/lightning/data/streaming/sampler.py
imports: import logging
  from dataclasses import dataclass
  from typing import Any, Dict, Iterator, List, Optional, Union
  import numpy
label_desc: Use image node_id 8 for calling the CacheBatchSampler obj's underlying member method code with example usage: obj.__iter_from_shuffled_chunks(shuffled_indexes, shuffled_chunk_intervals) without return types