






import pytest

from datasets.parallel import ParallelBackendConfig, parallel_backend
from datasets.utils.py_utils import map_nested

from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows




def      lowercase__      (     __snake_case    :							Optional[int]  ):  # picklable for multiprocessing


					'''simple docstring'''


					return i + 1




@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def      lowercase__      (     ):


					'''simple docstring'''


					with parallel_backend('spark'  ):
										assert ParallelBackendConfig.backend_name == "spark"

					UpperCAmelCase_    :      str            =						[1, 2, 3]
					with pytest.raises(__snake_case  ):
										with parallel_backend('unsupported backend'  ):
															map_nested(__snake_case     ,       __snake_case     ,       num_proc=2  )

					with pytest.raises(__snake_case  ):
										with parallel_backend('unsupported backend'  ):
															map_nested(__snake_case     ,       __snake_case     ,       num_proc=-1  )






@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
@pytest.mark.parametrize('num_proc'     ,       [2, -1]  )
def      lowercase__      (     __snake_case    :							Dict  ):


					'''simple docstring'''


					UpperCAmelCase_    :      Dict            =						[1, 2]
					UpperCAmelCase_    :      Any            =						{'a': 1, 'b': 2}
					UpperCAmelCase_    :      Any            =						{'a': [1, 2], 'b': [3, 4]}
					UpperCAmelCase_    :      Optional[Any]            =						{'a': {'1': 1}, 'b': 2}
					UpperCAmelCase_    :      Optional[int]            =						{'a': 1, 'b': 2, 'c': 3, 'd': 4}
					UpperCAmelCase_    :      Tuple            =						[2, 3]
					UpperCAmelCase_    :      Optional[int]            =						{'a': 2, 'b': 3}
					UpperCAmelCase_    :      Optional[int]            =						{'a': [2, 3], 'b': [4, 5]}
					UpperCAmelCase_    :      int            =						{'a': {'1': 2}, 'b': 3}
					UpperCAmelCase_    :      str            =						{'a': 2, 'b': 3, 'c': 4, 'd': 5}

					with parallel_backend('spark'  ):
										assert map_nested(__snake_case     ,       __snake_case     ,       num_proc=__snake_case  ) == expected_map_nested_sa
										assert map_nested(__snake_case     ,       __snake_case     ,       num_proc=__snake_case  ) == expected_map_nested_sa
										assert map_nested(__snake_case     ,       __snake_case     ,       num_proc=__snake_case  ) == expected_map_nested_sa
										assert map_nested(__snake_case     ,       __snake_case     ,       num_proc=__snake_case  ) == expected_map_nested_sa
										assert map_nested(__snake_case     ,       __snake_case     ,       num_proc=__snake_case  ) == expected_map_nested_sa














def      lowercase__      (     __snake_case    :							list  ):


					'''simple docstring'''


					for i in range(len(__snake_case  ) - 1     ,       0     ,       -1  ):
										UpperCAmelCase_    :      Dict            =						False

										for j in range(__snake_case     ,       0     ,       -1  ):
															if unsorted[j] < unsorted[j - 1]:
																				UpperCAmelCase_       ,  UpperCAmelCase_    :      Any            =						unsorted[j - 1], unsorted[j]
																				UpperCAmelCase_    :      int            =						True

										for j in range(__snake_case  ):
															if unsorted[j] > unsorted[j + 1]:
																				UpperCAmelCase_       ,  UpperCAmelCase_    :      Optional[int]            =						unsorted[j + 1], unsorted[j]
																				UpperCAmelCase_    :      Any            =						True

										if not swapped:
															break
					return unsorted


if __name__ == "__main__":
		import doctest

		doctest.testmod()
		__UpperCAmelCase								=						input('Enter numbers separated by a comma:\n').strip()
		__UpperCAmelCase								=						[int(item) for item in user_input.split(',')]
		print(F'{cocktail_shaker_sort(unsorted) = }')






