

'''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__       (    _SCREAMING_SNAKE_CASE   :       Optional[int]				)     ->					Any:  # picklable for multiprocessing


	"""simple docstring"""





	return i + 1


@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def  a__       (    )     ->					int:


	"""simple docstring"""





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

	UpperCAmelCase_     :      List[str]						=  [1, 2, 3]
	with pytest.raises(_SCREAMING_SNAKE_CASE				):
		with parallel_backend("unsupported backend"				):
			map_nested(_SCREAMING_SNAKE_CASE	,				_SCREAMING_SNAKE_CASE	,				num_proc=2				)

	with pytest.raises(_SCREAMING_SNAKE_CASE				):
		with parallel_backend("unsupported backend"				):
			map_nested(_SCREAMING_SNAKE_CASE	,				_SCREAMING_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__       (    _SCREAMING_SNAKE_CASE   :       str				)     ->					str:


	"""simple docstring"""





	UpperCAmelCase_     :      Optional[int]						=  [1, 2]
	UpperCAmelCase_     :      str						=  {"a": 1, "b": 2}
	UpperCAmelCase_     :      List[Any]						=  {"a": [1, 2], "b": [3, 4]}
	UpperCAmelCase_     :      Optional[Any]						=  {"a": {"1": 1}, "b": 2}
	UpperCAmelCase_     :      Optional[int]						=  {"a": 1, "b": 2, "c": 3, "d": 4}
	UpperCAmelCase_     :      str						=  [2, 3]
	UpperCAmelCase_     :      Union[str, Any]						=  {"a": 2, "b": 3}
	UpperCAmelCase_     :      int						=  {"a": [2, 3], "b": [4, 5]}
	UpperCAmelCase_     :      Dict						=  {"a": {"1": 2}, "b": 3}
	UpperCAmelCase_     :      Any						=  {"a": 2, "b": 3, "c": 4, "d": 5}

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









'''simple docstring'''






from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCAmelCase:   Optional[int]					=		logging.get_logger(__name__)

lowerCAmelCase:   int					=		{'ctrl': 'https://huggingface.co/ctrl/resolve/main/config.json'}

class 				a__(   lowerCamelCase__      ):
    lowercase__					=       """ctrl"""
    lowercase__					=       ["""past_key_values"""]
    lowercase__					=       {
        """max_position_embeddings""": """n_positions""",
        """hidden_size""": """n_embd""",
        """num_attention_heads""": """n_head""",
        """num_hidden_layers""": """n_layer""",
    }







    def __init__( self					:    Optional[int]		,     __snake_case					:    Union[str, Any]=24_65_34		,     __snake_case					:    Dict=2_56		,     __snake_case					:    Optional[int]=12_80		,     __snake_case					:    Optional[int]=81_92		,     __snake_case					:    Union[str, Any]=48		,     __snake_case					:    str=16		,     __snake_case					:    Any=0.1		,     __snake_case					:    List[Any]=0.1		,     __snake_case					:    str=1e-6		,     __snake_case					:    List[str]=0.02		,     __snake_case					:    int=True		,     **__snake_case					:    Any		,     ):
      a		:   int	  =	vocab_size
      a		:   Union[str, Any]	  =	n_positions
      a		:   Optional[int]	  =	n_embd
      a		:   Dict	  =	n_layer
      a		:   Union[str, Any]	  =	n_head
      a		:   Tuple	  =	dff
      a		:   Union[str, Any]	  =	resid_pdrop
      a		:   Tuple	  =	embd_pdrop
      a		:   int	  =	layer_norm_epsilon
      a		:   str	  =	initializer_range

      a		:   Any	  =	use_cache

      super().__init__(**__snake_case      )