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      (						A_   : Dict					)    ->  List[str]:  # picklable for multiprocessing
  return i + 1




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

  __UpperCAmelCase						    =       [1, 2, 3]
  with pytest.raises(A_					):
    with parallel_backend("unsupported backend"					):
      map_nested(A_						,	A_						,	num_proc=2					)

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





@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
@pytest.mark.parametrize("num_proc"						,	[2, -1]					)
def       __lowerCAmelCase      (						A_   : Any					)    ->  Optional[int]:
  __UpperCAmelCase						    =       [1, 2]
  __UpperCAmelCase						    =       {"a": 1, "b": 2}
  __UpperCAmelCase						    =       {"a": [1, 2], "b": [3, 4]}
  __UpperCAmelCase						    =       {"a": {"1": 1}, "b": 2}
  __UpperCAmelCase						    =       {"a": 1, "b": 2, "c": 3, "d": 4}
  __UpperCAmelCase						    =       [2, 3]
  __UpperCAmelCase						    =       {"a": 2, "b": 3}
  __UpperCAmelCase						    =       {"a": [2, 3], "b": [4, 5]}
  __UpperCAmelCase						    =       {"a": {"1": 2}, "b": 3}
  __UpperCAmelCase						    =       {"a": 2, "b": 3, "c": 4, "d": 5}

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




import copy
from dataclasses import dataclass
from pathlib import Path
from typing import Dict, Optional, Union


@dataclass
class 			UpperCAmelCase__    :



  """simple docstring"""






  lowerCAmelCase__		:	Optional[Union[str, Path]]    		= None
  lowerCAmelCase__		:	bool    		= False
  lowerCAmelCase__		:	bool    		= False
  lowerCAmelCase__		:	bool    		= False
  lowerCAmelCase__		:	Optional[Dict]    		= None
  lowerCAmelCase__		:	Optional[str]    		= None
  lowerCAmelCase__		:	bool    		= False
  lowerCAmelCase__		:	bool    		= False
  lowerCAmelCase__		:	bool    		= False
  lowerCAmelCase__		:	bool    		= True
  lowerCAmelCase__		:	Optional[int]    		= None
  lowerCAmelCase__		:	int    		= 1
  lowerCAmelCase__		:	Optional[Union[str, bool]]    		= None
  lowerCAmelCase__		:	bool    		= False
  lowerCAmelCase__		:	Optional[Dict]    		= None
  lowerCAmelCase__		:	Optional[str]    		= None






  def 	_UpperCAmelCase				(				self:			Any   ) -> "DownloadConfig":




    '''simple docstring'''




    return self.__class__(**{k: copy.deepcopy(__lowerCAmelCase   ) for k, v in self.__dict__.items()}   )



