






"""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 			_snake_case    (					lowerCamelCase__     :   Any  )    ->     Union[str, Any]:  # picklable for multiprocessing
							return i + 1

@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def 			_snake_case    (					)    ->     List[Any]:
							with parallel_backend("spark"  ):
														assert ParallelBackendConfig.backend_name == "spark"

							lowerCamelCase_	:							Optional[Any]									=[1, 2, 3]
							with pytest.raises(lowerCamelCase__  ):
														with parallel_backend("unsupported backend"  ):
																					map_nested(lowerCamelCase__    ,						lowerCamelCase__    ,						num_proc=2  )

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

@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
@pytest.mark.parametrize("num_proc"    ,						[2, -1]  )
def 			_snake_case    (					lowerCamelCase__     :   Tuple  )    ->     Optional[Any]:
							lowerCamelCase_	:							str									=[1, 2]
							lowerCamelCase_	:							List[str]									={"a": 1, "b": 2}
							lowerCamelCase_	:							List[str]									={"a": [1, 2], "b": [3, 4]}
							lowerCamelCase_	:							Optional[int]									={"a": {"1": 1}, "b": 2}
							lowerCamelCase_	:							int									={"a": 1, "b": 2, "c": 3, "d": 4}
							lowerCamelCase_	:							Optional[int]									=[2, 3]
							lowerCamelCase_	:							List[Any]									={"a": 2, "b": 3}
							lowerCamelCase_	:							int									={"a": [2, 3], "b": [4, 5]}
							lowerCamelCase_	:							str									={"a": {"1": 2}, "b": 3}
							lowerCamelCase_	:							Dict									={"a": 2, "b": 3, "c": 4, "d": 5}

							with parallel_backend("spark"  ):
														assert map_nested(lowerCamelCase__    ,						lowerCamelCase__    ,						num_proc=lowerCamelCase__  ) == expected_map_nested_sa
														assert map_nested(lowerCamelCase__    ,						lowerCamelCase__    ,						num_proc=lowerCamelCase__  ) == expected_map_nested_sa
														assert map_nested(lowerCamelCase__    ,						lowerCamelCase__    ,						num_proc=lowerCamelCase__  ) == expected_map_nested_sa
														assert map_nested(lowerCamelCase__    ,						lowerCamelCase__    ,						num_proc=lowerCamelCase__  ) == expected_map_nested_sa
														assert map_nested(lowerCamelCase__    ,						lowerCamelCase__    ,						num_proc=lowerCamelCase__  ) == expected_map_nested_sa











"""simple docstring"""



import torch

def 			_snake_case    (					)    ->     Union[str, Any]:
							if torch.cuda.is_available():
														lowerCamelCase_	:							int									=torch.cuda.device_count()
							else:
														lowerCamelCase_	:							List[str]									=0
							print(F"""Successfully ran on {num_gpus} GPUs"""  )


if __name__ == "__main__":
						main()



