




"""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     a__ (				snake_case__				)						->					Any:  # picklable for multiprocessing
			return i + 1



@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def     a__ (				)						->					Union[str, Any]:
			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     a__ (				snake_case__				)						->					List[Any]:
			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"""




def     a__ (				snake_case__       , snake_case__ = False				)						->					str:

			if not isinstance(snake_case__       , snake_case__				):
						lowerCamelCase			      =					F'Expected string as input, found {type(snake_case__				)}'
						raise ValueError(snake_case__				)
			if not isinstance(snake_case__       , snake_case__				):
						lowerCamelCase			      =					F'Expected boolean as use_pascal parameter, found {type(snake_case__				)}'
						raise ValueError(snake_case__				)

			lowerCamelCase			      =					input_str.split("""_"""				)

			lowerCamelCase			      =					0 if use_pascal else 1

			lowerCamelCase			      =					words[start_index:]

			lowerCamelCase			      =					[word[0].upper() + word[1:] for word in words_to_capitalize]

			lowerCamelCase			      =					"""""" if use_pascal else words[0]

			return "".join([initial_word, *capitalized_words]				)


if __name__ == "__main__":
					from doctest import testmod

					testmod()



