
"""simple docstring"""





# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

# rely on isort to merge the imports
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


__magic_name__       =			{
    "configuration_vivit": ["VIVIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "VivitConfig"],
}
try:
							if not is_vision_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							__magic_name__       =			["VivitImageProcessor"]


try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							__magic_name__       =			[
							    "VIVIT_PRETRAINED_MODEL_ARCHIVE_LIST",
							    "VivitModel",
							    "VivitPreTrainedModel",
							    "VivitForVideoClassification",
							]


if TYPE_CHECKING:
							from .configuration_vivit import VIVIT_PRETRAINED_CONFIG_ARCHIVE_MAP, VivitConfig

							try:
														if not is_vision_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .image_processing_vivit import VivitImageProcessor

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_vivit import (
														    VIVIT_PRETRAINED_MODEL_ARCHIVE_LIST,
														    VivitForVideoClassification,
														    VivitModel,
														    VivitPreTrainedModel,
														)


else:
							import sys

							__magic_name__       =			_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)






"""simple docstring"""





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(UpperCamelCase_  ,				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 						_lowerCAmelCase				(				UpperCamelCase_  ,				UpperCamelCase_				):
		__SCREAMING_SNAKE_CASE            = _distribute_shards(**UpperCamelCase_				)
		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 						_lowerCAmelCase				(				UpperCamelCase_  ,				UpperCamelCase_  ,				UpperCamelCase_				):
		__SCREAMING_SNAKE_CASE            = _split_gen_kwargs(UpperCamelCase_  ,				UpperCamelCase_				)
		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 						_lowerCAmelCase				(				UpperCamelCase_  ,				UpperCamelCase_				):
		if expected is RuntimeError:
				with pytest.raises(UpperCamelCase_				):
						_number_of_shards_in_gen_kwargs(UpperCamelCase_				)
		else:
				__SCREAMING_SNAKE_CASE            = _number_of_shards_in_gen_kwargs(UpperCamelCase_				)
				assert out == expected




