



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(_lowerCamelCase							,			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__				(							lowercase							,			lowercase ):
   SCREAMING_SNAKE_CASE_: str     			=_distribute_shards(**_lowerCamelCase )
   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__				(							lowercase							,			lowercase							,			lowercase ):
   SCREAMING_SNAKE_CASE_: str     			=_split_gen_kwargs(_lowerCamelCase							,			_lowerCamelCase )
   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__				(							lowercase							,			lowercase ):


   if expected is RuntimeError:
      with pytest.raises(_lowerCamelCase ):
         _number_of_shards_in_gen_kwargs(_lowerCamelCase )
   else:
      SCREAMING_SNAKE_CASE_: Dict     			=_number_of_shards_in_gen_kwargs(_lowerCamelCase )
      assert out == expected








"""simple docstring"""
from __future__ import annotations





def      __magic_name__				(							lowercase							,			lowercase ):
   SCREAMING_SNAKE_CASE_: List[Any]     			=sorted(numsa + numsa )
   SCREAMING_SNAKE_CASE_			,		SCREAMING_SNAKE_CASE_: Tuple     			=divmod(len(lowercase )							,			2 )
   if mod == 1:
      return all_numbers[div]
   else:
      return (all_numbers[div] + all_numbers[div - 1]) / 2


if __name__ == "__main__":
   import doctest

   doctest.testmod()
   _UpperCAmelCase     =			[float(x) for x in input("""Enter the elements of first array: """).split()]
   _UpperCAmelCase     =			[float(x) for x in input("""Enter the elements of second array: """).split()]
   print(f"""The median of two arrays is: {median_of_two_arrays(array_a, array_a)}""")



