�
���g� � �� � d dl Z d dlmZmZ d dlmZ ddlmZmZ ej e
� � Z G d� d� � Zed� � � Z
d � Zd
� Zee j defd�� � � � ZdS )
� N)�Pool�RLock)�tqdm� )�experimental�loggingc � � e Zd ZdZdS )�ParallelBackendConfigN)�__name__�
__module__�__qualname__�backend_name� � �j/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/datasets/parallel/parallel.pyr
r
s � � � � � ��L�L�Lr r
c �v � t j �t | ||||||||� � S t | ||||||||� � S )a�
**Experimental.** Apply a function to iterable elements in parallel, where the implementation uses either
multiprocessing.Pool or joblib for parallelization.
Args:
function (`Callable[[Any], Any]`): Function to be applied to `iterable`.
iterable (`list`, `tuple` or `np.ndarray`): Iterable elements to apply function to.
num_proc (`int`): Number of processes (if no backend specified) or jobs (using joblib).
types (`tuple`): Additional types (besides `dict` values) to apply `function` recursively to their elements.
disable_tqdm (`bool`): Whether to disable the tqdm progressbar.
desc (`str`): Prefix for the tqdm progressbar.
single_map_nested_func (`Callable`): Map function that applies `function` to an element from `iterable`.
Takes a tuple of function, data_struct, types, rank, disable_tqdm, desc as input, where data_struct is an
element of `iterable`, and `rank` is used for progress bar.
)r
r �_map_with_multiprocessing_pool�_map_with_joblib) �function�iterable�num_proc�batched�
batch_size�types�disable_tqdm�desc�single_map_nested_funcs r �parallel_mapr s] � �"