code: def _associate_chunks_to_workers(
      num_workers: int,
      worker_env: _WorkerEnv,
      chunks_replica: List[int],
      intervals_replica: List[Any],
  ) -> Any:
      workers_chunks = {}
      workers_intervals = {}
  
      for worker_idx in range(num_workers):
          worker_chunks = []
          worker_intervals = []
          for i, (chunk_index, chunk_interval) in enumerate(
              zip(chunks_replica, intervals_replica)
          ):
              if i % worker_env.world_size != worker_idx:
                  continue
  
              worker_chunks.append(chunk_index)
              worker_intervals.append(chunk_interval)
  
          workers_chunks[worker_idx] = worker_chunks
          workers_intervals[worker_idx] = worker_intervals
  
      return workers_chunks, workers_intervals
  
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 5 for calling a global function with example usage: _associate_chunks_to_workers(num_workers, worker_env, chunks_replica, intervals_replica) and returns: workers_chunks,  workers_intervals