def _build_shuffle_index(
    num_samples: int, total_size: int, numpy_random_state: numpy.random.RandomState,
    enable_shuffle: bool = False,
) -> numpy.ndarray:
    """Build the range [0, size) and shuffle

    Args:
        num_samples (int): The size of the first shuffle range [0, num_samples)

        total_size (int): The size of the entire index. If larger than 'num_samples', it defines

        the second shuffle range [num_samples, total_size)

        numpy_random_state (numpy.random.RandomState): The NumPy random state

    Returns:
        numpy.ndarray: The shuffle index

    TODO: Explain [0, num_samples) [num_samples, total_size) split
    """
    dtype_ = numpy.uint32
    if total_size >= (numpy.iinfo(numpy.uint32).max - 1):
        dtype_ = numpy.int64

    shuffle_idx_first = numpy.arange(start=0, stop=num_samples, step=1, dtype=dtype_)
    if enable_shuffle:
        print("INFO: shuffle_index shuffle is enabled...")
        numpy_random_state.shuffle(shuffle_idx_first)
    else:
        print("INFO: shuffle_index shuffle is disabled...")
    if num_samples == total_size:
        return shuffle_idx_first

    shuffle_idx_last = numpy.arange(start=num_samples, stop=total_size, step=1, dtype=dtype_)
    if enable_shuffle:
        print("INFO: shuffle_index shuffle is enabled...")
        numpy_random_state.shuffle(shuffle_idx_last)
    else:
        print("INFO: shuffle_index shuffle is disabled...")

    return numpy.concatenate((shuffle_idx_first, shuffle_idx_last))
Build the range [0, size) and shuffle

    Args:
        num_samples (int): The size of the first shuffle range [0, num_samples)

        total_size (int): The size of the entire index. If larger than 'num_samples', it defines

        the second shuffle range [num_samples, total_size)

        numpy_random_state (numpy.random.RandomState): The NumPy random state

    Returns:
        numpy.ndarray: The shuffle index

    TODO: Explain [0, num_samples) [num_samples, total_size) split
    
finetune/core/datasets/gpt_dataset.py