"""simple docstring"""


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


__UpperCamelCase									=			logging.get_logger(__name__)

__UpperCamelCase									=			{
    '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/small/resolve/main/config.json''',
    '''funnel-transformer/small-base''': '''https://huggingface.co/funnel-transformer/small-base/resolve/main/config.json''',
    '''funnel-transformer/medium''': '''https://huggingface.co/funnel-transformer/medium/resolve/main/config.json''',
    '''funnel-transformer/medium-base''': '''https://huggingface.co/funnel-transformer/medium-base/resolve/main/config.json''',
    '''funnel-transformer/intermediate''': (
        '''https://huggingface.co/funnel-transformer/intermediate/resolve/main/config.json'''
    ),
    '''funnel-transformer/intermediate-base''': (
        '''https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/config.json'''
    ),
    '''funnel-transformer/large''': '''https://huggingface.co/funnel-transformer/large/resolve/main/config.json''',
    '''funnel-transformer/large-base''': '''https://huggingface.co/funnel-transformer/large-base/resolve/main/config.json''',
    '''funnel-transformer/xlarge''': '''https://huggingface.co/funnel-transformer/xlarge/resolve/main/config.json''',
    '''funnel-transformer/xlarge-base''': '''https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/config.json''',
}




class  UpperCamelCase					(				lowerCAmelCase__   ):
       SCREAMING_SNAKE_CASE_			=      "funnel"
       SCREAMING_SNAKE_CASE_			=      {
           "hidden_size": "d_model",
           "num_attention_heads": "n_head",
       }







       def __init__( self,							lowerCAmelCase__=3_0522,							lowerCAmelCase__=[4, 4, 4],							lowerCAmelCase__=None,							lowerCAmelCase__=2,							lowerCAmelCase__=768,							lowerCAmelCase__=12,							lowerCAmelCase__=64,							lowerCAmelCase__=3072,							lowerCAmelCase__="gelu_new",							lowerCAmelCase__=0.1,							lowerCAmelCase__=0.1,							lowerCAmelCase__=0.0,							lowerCAmelCase__=0.1,							lowerCAmelCase__=None,							lowerCAmelCase__=1e-9,							lowerCAmelCase__="mean",							lowerCAmelCase__="relative_shift",							lowerCAmelCase__=True,							lowerCAmelCase__=True,							lowerCAmelCase__=True,							**lowerCAmelCase__,							)      ->      Union[str, Any]:
            snake_case_					       =					vocab_size
            snake_case_					       =					block_sizes
            snake_case_					       =					[1] * len(lowerCAmelCase__) if block_repeats is None else block_repeats
            assert len(lowerCAmelCase__) == len(
                self.block_repeats), "`block_sizes` and `block_repeats` should have the same length."
            snake_case_					       =					num_decoder_layers
            snake_case_					       =					d_model
            snake_case_					       =					n_head
            snake_case_					       =					d_head
            snake_case_					       =					d_inner
            snake_case_					       =					hidden_act
            snake_case_					       =					hidden_dropout
            snake_case_					       =					attention_dropout
            snake_case_					       =					activation_dropout
            snake_case_					       =					initializer_range
            snake_case_					       =					initializer_std
            snake_case_					       =					layer_norm_eps
            assert pooling_type in [
                "mean",
                "max",
            ], f'Got {pooling_type} for `pooling_type` but only \'mean\' and \'max\' are supported.'
            snake_case_					       =					pooling_type
            assert attention_type in [
                "relative_shift",
                "factorized",
            ], f'Got {attention_type} for `attention_type` but only \'relative_shift\' and \'factorized\' are supported.'
            snake_case_					       =					attention_type
            snake_case_					       =					separate_cls
            snake_case_					       =					truncate_seq
            snake_case_					       =					pool_q_only

            super().__init__(**lowerCAmelCase__)







       @property
       def 		a_						( self)      ->      Optional[Any]:
            return sum(self.block_sizes)







       @num_hidden_layers.setter
       def 		a_						( self,							lowerCAmelCase__)      ->      Tuple:
            raise NotImplementedError(
                'This model does not support the setting of `num_hidden_layers`. Please set `block_sizes`.')







       @property
       def 		a_						( self)      ->      Optional[int]:
            return len(self.block_sizes)







       @num_blocks.setter
       def 		a_						( self,							lowerCAmelCase__)      ->      List[Any]:
            raise NotImplementedError('This model does not support the setting of `num_blocks`. Please set `block_sizes`.')








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__(__snake_case							)				->      int:  # picklable for multiprocessing







	'''simple docstring'''







	return i + 1





@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def lowerCAmelCase__()				->      Any:







	'''simple docstring'''







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

	lowerCamelCase__								=		[1, 2, 3]
	with pytest.raises(__snake_case							):
		with parallel_backend('''unsupported backend'''							):
			map_nested(__snake_case       ,__snake_case       ,num_proc=2							)

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





@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
@pytest.mark.parametrize('''num_proc'''       ,[2, -1]							)
def lowerCAmelCase__(__snake_case							)				->      Tuple:







	'''simple docstring'''







	lowerCamelCase__								=		[1, 2]
	lowerCamelCase__								=		{'''a''': 1, '''b''': 2}
	lowerCamelCase__								=		{'''a''': [1, 2], '''b''': [3, 4]}
	lowerCamelCase__								=		{'''a''': {'''1''': 1}, '''b''': 2}
	lowerCamelCase__								=		{'''a''': 1, '''b''': 2, '''c''': 3, '''d''': 4}
	lowerCamelCase__								=		[2, 3]
	lowerCamelCase__								=		{'''a''': 2, '''b''': 3}
	lowerCamelCase__								=		{'''a''': [2, 3], '''b''': [4, 5]}
	lowerCamelCase__								=		{'''a''': {'''1''': 2}, '''b''': 3}
	lowerCamelCase__								=		{'''a''': 2, '''b''': 3, '''c''': 4, '''d''': 5}

	with parallel_backend('''spark'''							):
		assert map_nested(__snake_case       ,__snake_case       ,num_proc=__snake_case							) == expected_map_nested_sa
		assert map_nested(__snake_case       ,__snake_case       ,num_proc=__snake_case							) == expected_map_nested_sa
		assert map_nested(__snake_case       ,__snake_case       ,num_proc=__snake_case							) == expected_map_nested_sa
		assert map_nested(__snake_case       ,__snake_case       ,num_proc=__snake_case							) == expected_map_nested_sa
		assert map_nested(__snake_case       ,__snake_case       ,num_proc=__snake_case							) == expected_map_nested_sa



