'''simple docstring'''

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 							UpperCamelCase__			(			a__      ):  # picklable for multiprocessing


						'''simple docstring'''






						return i + 1

@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def 							UpperCamelCase__			(			):


						'''simple docstring'''






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

						_lowerCAmelCase										=[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 							UpperCamelCase__			(			a__      ):


						'''simple docstring'''






						_lowerCAmelCase										=[1, 2]
						_lowerCAmelCase										={'a': 1, 'b': 2}
						_lowerCAmelCase										={'a': [1, 2], 'b': [3, 4]}
						_lowerCAmelCase										={'a': {'1': 1}, 'b': 2}
						_lowerCAmelCase										={'a': 1, 'b': 2, 'c': 3, 'd': 4}
						_lowerCAmelCase										=[2, 3]
						_lowerCAmelCase										={'a': 2, 'b': 3}
						_lowerCAmelCase										={'a': [2, 3], 'b': [4, 5]}
						_lowerCAmelCase										={'a': {'1': 2}, 'b': 3}
						_lowerCAmelCase										={'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






'''simple docstring'''

from __future__ import annotations



def 							UpperCamelCase__			(			a__      ):


						'''simple docstring'''






						_lowerCAmelCase										=len(a__      ) // 2

						# choose the middle 3 elements
						_lowerCAmelCase										=lst[m - 1 : m + 2]

						# if middle element is peak
						if three[1] > three[0] and three[1] > three[2]:
												return three[1]

						# if increasing, recurse on right
						elif three[0] < three[2]:
												if len(lst[:m]      ) == 2:
																		m -= 1
												return peak(lst[m:]      )

						# decreasing
						else:
												if len(lst[:m]      ) == 2:
																		m += 1
												return peak(lst[:m]      )


if __name__ == "__main__":
							import doctest

							doctest.testmod()





