def METHOD_NAME(
    dataset: "deeplake.core.dataset.Dataset",
    primary_tensor_name: str,
    shuffle_within_chunks: bool = False,
):
    slice_ = dataset.index.values[0].value
    index_struct: Union[set, dict, None] = None
    if isinstance(slice_, int):
        return None
    elif isinstance(slice_, slice):
        start = slice_.start if slice_.start is not None else 0
        stop = slice_.stop if slice_.stop is not None else dataset.min_len
        step = slice_.step if slice_.step is not None else 1
        index_struct = set(range(start, stop, step))
    elif isinstance(slice_, (list, tuple)):
        index_struct = defaultdict(lambda: 0)
        for item in slice_:
            index_struct[item] += 1
    primary_tensor = dataset[primary_tensor_name]
    chunk_id_encoder: ChunkIdEncoder = primary_tensor.chunk_engine.chunk_id_encoder
    enc_array = chunk_id_encoder.array
    num_chunks = chunk_id_encoder.num_chunks
    # pick chunks randomly, one by one
    prev_state = np.random.get_state()
    np.random.seed(DeeplakeRandom().get_seed())
    chunk_order = np.random.choice(num_chunks, num_chunks, replace=False)
    schedule: List[Any] = []
    for chunk_idx in chunk_order:
        start_index = int(enc_array[chunk_idx - 1][1]) + 1 if chunk_idx > 0 else 0
        last_index = int(enc_array[chunk_idx][1]) + 1
        indexes = np.arange(start_index, last_index)
        if shuffle_within_chunks:
            np.random.shuffle(indexes)
        schedule.extend(indexes)
    if isinstance(index_struct, set):
        schedule = [int(idx) for idx in schedule if idx in index_struct]
    elif isinstance(index_struct, dict):
        idxs = filter(lambda idx: idx in index_struct, schedule)  # type: ignore
        schedule = [int(idx) for idx in idxs for _ in range(index_struct[idx])]
    np.random.set_state(prev_state)
    return schedule