


'''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  __lowerCAmelCase (__lowerCAmelCase   ):  # picklable for multiprocessing
		return i + 1






@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def  __lowerCAmelCase ():
		with parallel_backend("spark"   ):
				assert ParallelBackendConfig.backend_name == "spark"

		_UpperCAmelCase		:       Union[str, 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  __lowerCAmelCase (__lowerCAmelCase   ):
		_UpperCAmelCase		:       Dict								=      [1, 2]
		_UpperCAmelCase		:       List[Any]								=      {"a": 1, "b": 2}
		_UpperCAmelCase		:       List[Any]								=      {"a": [1, 2], "b": [3, 4]}
		_UpperCAmelCase		:       Tuple								=      {"a": {"1": 1}, "b": 2}
		_UpperCAmelCase		:       List[str]								=      {"a": 1, "b": 2, "c": 3, "d": 4}
		_UpperCAmelCase		:       Tuple								=      [2, 3]
		_UpperCAmelCase		:       str								=      {"a": 2, "b": 3}
		_UpperCAmelCase		:       int								=      {"a": [2, 3], "b": [4, 5]}
		_UpperCAmelCase		:       Optional[Any]								=      {"a": {"1": 2}, "b": 3}
		_UpperCAmelCase		:       List[str]								=      {"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'''


from ...utils import (
    OptionalDependencyNotAvailable,
    is_flax_available,
    is_torch_available,
    is_transformers_available,
)


try:
						if not (is_transformers_available() and is_torch_available()):
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						from ...utils.dummy_torch_and_transformers_objects import *  # noqa F403
else:
						from .multicontrolnet import MultiControlNetModel
						from .pipeline_controlnet import StableDiffusionControlNetPipeline
						from .pipeline_controlnet_imgaimg import StableDiffusionControlNetImgaImgPipeline
						from .pipeline_controlnet_inpaint import StableDiffusionControlNetInpaintPipeline


if is_transformers_available() and is_flax_available():
						from .pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline



