nemo_curator.utils.grouping
Utility Functions for grouping iterables.
This module provides a collection of utility functions designed to assist with common tasks related to manipulating and transforming iterables in Python.
These utilities are generic and work with any iterable types. They’re particularly useful for data processing tasks, batching operations, and other scenarios where dividing data into specific groupings is necessary.
Module Contents
Functions
Data
API
Return pairs of consecutive items from the input iterable.
Parameters:
The input iterable.
Returns: Iterable[tuple[T, T]]
Iterable[tuple[T, T]]: Pairs of consecutive items.
Split an iterable into chunks of the specified size.
Yields:
- Generator[list[T], None, None]: Chunks of the input iterable.
Parameters:
The input iterable to be split.
Size of each chunk.
function
If True, drops the last chunk if its size is less than the specified chunk size. Defaults to False.
Split an iterable into a specified number of chunks.
Yields:
- Generator[list[T], None, None]: Chunks of the input iterable.
Parameters:
The input iterable to be split.
The desired number of chunks.