
import pytest

from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs






@pytest.mark.parametrize(
    """kwargs, expected"""	,		[
        ({"""num_shards""": 0, """max_num_jobs""": 1}, []),
        ({"""num_shards""": 10, """max_num_jobs""": 1}, [range(10						)]),
        ({"""num_shards""": 10, """max_num_jobs""": 10}, [range(_a	,		i + 1						) for i in range(10						)]),
        ({"""num_shards""": 1, """max_num_jobs""": 10}, [range(1						)]),
        ({"""num_shards""": 10, """max_num_jobs""": 3}, [range(0	,		4						), range(4	,		7						), range(7	,		10						)]),
        ({"""num_shards""": 3, """max_num_jobs""": 10}, [range(0	,		1						), range(1	,		2						), range(2	,		3						)]),
    ]	,		)
def 						__magic_name__			(   __a      :	str	,		__a      :	Optional[Any]						):



					'''simple docstring'''




					UpperCamelCase__				=    _distribute_shards(**_a						)
					assert out == expected






@pytest.mark.parametrize(
    """gen_kwargs, max_num_jobs, expected"""	,		[
        ({"""foo""": 0}, 10, [{"""foo""": 0}]),
        ({"""shards""": [0, 1, 2, 3]}, 1, [{"""shards""": [0, 1, 2, 3]}]),
        ({"""shards""": [0, 1, 2, 3]}, 4, [{"""shards""": [0]}, {"""shards""": [1]}, {"""shards""": [2]}, {"""shards""": [3]}]),
        ({"""shards""": [0, 1]}, 4, [{"""shards""": [0]}, {"""shards""": [1]}]),
        ({"""shards""": [0, 1, 2, 3]}, 2, [{"""shards""": [0, 1]}, {"""shards""": [2, 3]}]),
    ]	,		)
def 						__magic_name__			(   __a      :	Optional[int]	,		__a      :	List[Any]	,		__a      :	Tuple						):



					'''simple docstring'''




					UpperCamelCase__				=    _split_gen_kwargs(_a	,		_a						)
					assert out == expected






@pytest.mark.parametrize(
    """gen_kwargs, expected"""	,		[
        ({"""foo""": 0}, 1),
        ({"""shards""": [0]}, 1),
        ({"""shards""": [0, 1, 2, 3]}, 4),
        ({"""shards""": [0, 1, 2, 3], """foo""": 0}, 4),
        ({"""shards""": [0, 1, 2, 3], """other""": (0, 1)}, 4),
        ({"""shards""": [0, 1, 2, 3], """shards2""": [0, 1]}, RuntimeError),
    ]	,		)
def 						__magic_name__			(   __a      :	Tuple	,		__a      :	Dict						):



					'''simple docstring'''




					if expected is RuntimeError:
										with pytest.raises(_a						):
															_number_of_shards_in_gen_kwargs(_a						)
					else:
										UpperCamelCase__				=    _number_of_shards_in_gen_kwargs(_a						)
										assert out == expected







from typing import TYPE_CHECKING

from ...utils import _LazyModule


lowerCamelCase_						     =					{'''processing_wav2vec2_with_lm''': ['''Wav2Vec2ProcessorWithLM''']}


if TYPE_CHECKING:
    from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM
else:
    import sys

    lowerCamelCase_						     =					_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)





