





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



			"""simple docstring"""


			return i + 1







@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def 					_a						(       ) ->				Tuple:



			"""simple docstring"""


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

			__snake_case					:      List[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 					_a						(       _lowerCamelCase ) ->				Union[str, Any]:



			"""simple docstring"""


			__snake_case					:      List[str]							      =     [1, 2]
			__snake_case					:      Tuple							      =     {"""a""": 1, """b""": 2}
			__snake_case					:      Union[str, Any]							      =     {"""a""": [1, 2], """b""": [3, 4]}
			__snake_case					:      Dict							      =     {"""a""": {"""1""": 1}, """b""": 2}
			__snake_case					:      Union[str, Any]							      =     {"""a""": 1, """b""": 2, """c""": 3, """d""": 4}
			__snake_case					:      int							      =     [2, 3]
			__snake_case					:      Union[str, Any]							      =     {"""a""": 2, """b""": 3}
			__snake_case					:      Tuple							      =     {"""a""": [2, 3], """b""": [4, 5]}
			__snake_case					:      Optional[int]							      =     {"""a""": {"""1""": 2}, """b""": 3}
			__snake_case					:      Optional[int]							      =     {"""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 ...configuration_utils import PretrainedConfig
from ...utils import logging


__UpperCAmelCase            =       logging.get_logger(__name__)

__UpperCAmelCase            =       {
    """google/fnet-base""": """https://huggingface.co/google/fnet-base/resolve/main/config.json""",
    """google/fnet-large""": """https://huggingface.co/google/fnet-large/resolve/main/config.json"""
    # See all FNet models at https://huggingface.co/models?filter=fnet
}




class      UpperCamelCase__					(					lowercase_			):




					"""simple docstring"""
					SCREAMING_SNAKE_CASE__				=	'''fnet'''


					def __init__(						self				:			Any      ,						lowerCamelCase_				:			List[str]=3_20_00      ,						lowerCamelCase_				:			List[Any]=7_68      ,						lowerCamelCase_				:			Union[str, Any]=12      ,						lowerCamelCase_				:			Optional[Any]=30_72      ,						lowerCamelCase_				:			Optional[Any]="gelu_new"      ,						lowerCamelCase_				:			Any=0.1      ,						lowerCamelCase_				:			Union[str, Any]=5_12      ,						lowerCamelCase_				:			Optional[int]=4      ,						lowerCamelCase_				:			Optional[int]=0.02      ,						lowerCamelCase_				:			str=1e-12      ,						lowerCamelCase_				:			Any=False      ,						lowerCamelCase_				:			str=5_12      ,						lowerCamelCase_				:			str=3      ,						lowerCamelCase_				:			int=1      ,						lowerCamelCase_				:			Optional[Any]=2      ,						**lowerCamelCase_				:			Optional[int]      ,						):

							'''simple docstring'''



							super().__init__(pad_token_id=lowerCamelCase_      ,						bos_token_id=lowerCamelCase_      ,						eos_token_id=lowerCamelCase_      ,						**lowerCamelCase_						)

							SCREAMING_SNAKE_CASE :				Dict		=			vocab_size
							SCREAMING_SNAKE_CASE :				Dict		=			max_position_embeddings
							SCREAMING_SNAKE_CASE :				str		=			hidden_size
							SCREAMING_SNAKE_CASE :				Optional[Any]		=			num_hidden_layers
							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			intermediate_size
							SCREAMING_SNAKE_CASE :				int		=			hidden_act
							SCREAMING_SNAKE_CASE :				Dict		=			hidden_dropout_prob
							SCREAMING_SNAKE_CASE :				Tuple		=			initializer_range
							SCREAMING_SNAKE_CASE :				List[Any]		=			type_vocab_size
							SCREAMING_SNAKE_CASE :				Any		=			layer_norm_eps
							SCREAMING_SNAKE_CASE :				int		=			use_tpu_fourier_optimizations
							SCREAMING_SNAKE_CASE :				List[Any]		=			tpu_short_seq_length



