





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


_a						=   logging.get_logger(__name__)

_a						=   {
    "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       __A					(					__lowercase				):

			'''simple docstring'''







			lowerCAmelCase_							  =		"""funnel"""
			lowerCAmelCase_							  =		{
			    """hidden_size""": """d_model""",
			    """num_attention_heads""": """n_head""",
			}





			def __init__(					self ,						__lowerCAmelCase=3_0_5_2_2 ,						__lowerCAmelCase=[4, 4, 4] ,						__lowerCAmelCase=None ,						__lowerCAmelCase=2 ,						__lowerCAmelCase=7_6_8 ,						__lowerCAmelCase=1_2 ,						__lowerCAmelCase=6_4 ,						__lowerCAmelCase=3_0_7_2 ,						__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 ,						):



				'''simple docstring'''







				lowerCamelCase__              =	vocab_size
				lowerCamelCase__              =	block_sizes
				lowerCamelCase__              =	[1] * len(_A							) if block_repeats is None else block_repeats
				assert len(_A							) == len(
				    self.block_repeats							), "`block_sizes` and `block_repeats` should have the same length."
				lowerCamelCase__              =	num_decoder_layers
				lowerCamelCase__              =	d_model
				lowerCamelCase__              =	n_head
				lowerCamelCase__              =	d_head
				lowerCamelCase__              =	d_inner
				lowerCamelCase__              =	hidden_act
				lowerCamelCase__              =	hidden_dropout
				lowerCamelCase__              =	attention_dropout
				lowerCamelCase__              =	activation_dropout
				lowerCamelCase__              =	initializer_range
				lowerCamelCase__              =	initializer_std
				lowerCamelCase__              =	layer_norm_eps
				assert pooling_type in [
				    "mean",
				    "max",
				], F'Got {pooling_type} for `pooling_type` but only \'mean\' and \'max\' are supported.'
				lowerCamelCase__              =	pooling_type
				assert attention_type in [
				    "relative_shift",
				    "factorized",
				], F'Got {attention_type} for `attention_type` but only \'relative_shift\' and \'factorized\' are supported.'
				lowerCamelCase__              =	attention_type
				lowerCamelCase__              =	separate_cls
				lowerCamelCase__              =	truncate_seq
				lowerCamelCase__              =	pool_q_only

				super().__init__(**_A							)





			@property
			def 	__lowerCamelCase       (					self							):



				'''simple docstring'''







				return sum(self.block_sizes							)





			@num_hidden_layers.setter
			def 	__lowerCamelCase       (					self ,						__lowerCAmelCase							):



				'''simple docstring'''







				raise NotImplementedError(
				    '''This model does not support the setting of `num_hidden_layers`. Please set `block_sizes`.'''							)





			@property
			def 	__lowerCamelCase       (					self							):



				'''simple docstring'''







				return len(self.block_sizes							)





			@num_blocks.setter
			def 	__lowerCamelCase       (					self ,						__lowerCAmelCase							):



				'''simple docstring'''







				raise NotImplementedError('''This model does not support the setting of `num_blocks`. Please set `block_sizes`.'''							)










import os
from collections import namedtuple

import pytest

from datasets import ClassLabel, Features, Sequence, Value
from datasets.commands.test import TestCommand
from datasets.info import DatasetInfo, DatasetInfosDict


_a						=   namedtuple(
    "_TestCommandArgs",
    [
        "dataset",
        "name",
        "cache_dir",
        "data_dir",
        "all_configs",
        "save_infos",
        "ignore_verifications",
        "force_redownload",
        "clear_cache",
    ],
    defaults=[None, None, None, False, False, False, False, False],
)





def lowerCAmelCase__(__snake_case ,__snake_case							)       ->   List[str]:







	'''simple docstring'''







	return (abs(source - target							) / target) < 0.0_1





@pytest.mark.integration
def lowerCAmelCase__(__snake_case							)       ->   Tuple:







	'''simple docstring'''







	lowerCamelCase__              =	_TestCommandArgs(dataset=__snake_case ,all_configs=__snake_case ,save_infos=__snake_case							)
	lowerCamelCase__              =	TestCommand(*__snake_case							)
	test_command.run()
	lowerCamelCase__              =	os.path.join(__snake_case ,'''README.md'''							)
	assert os.path.exists(__snake_case							)
	lowerCamelCase__              =	DatasetInfosDict.from_directory(__snake_case							)
	lowerCamelCase__              =	DatasetInfosDict(
	    {
	        '''default''': DatasetInfo(
	            features=Features(
	                {
	                    '''tokens''': Sequence(Value('''string'''							)							),
	                    '''ner_tags''': Sequence(
	                        ClassLabel(names=['''O''', '''B-PER''', '''I-PER''', '''B-ORG''', '''I-ORG''', '''B-LOC''', '''I-LOC''']							)							),
	                    '''langs''': Sequence(Value('''string'''							)							),
	                    '''spans''': Sequence(Value('''string'''							)							),
	                }							) ,splits=[
	                {
	                    '''name''': '''train''',
	                    '''num_bytes''': 2351563,
	                    '''num_examples''': 10000,
	                },
	                {
	                    '''name''': '''validation''',
	                    '''num_bytes''': 238418,
	                    '''num_examples''': 1000,
	                },
	            ] ,download_size=3940680 ,dataset_size=2589981 ,)
	    }							)
	assert dataset_infos.keys() == expected_dataset_infos.keys()
	for key in DatasetInfo._INCLUDED_INFO_IN_YAML:
		lowerCamelCase__       ,			lowerCamelCase__              =	getattr(dataset_infos['''default'''] ,__snake_case							), getattr(expected_dataset_infos['''default'''] ,__snake_case							)
		if key == "num_bytes":
			assert is_apercent_close(__snake_case ,__snake_case							)
		elif key == "splits":
			assert list(__snake_case							) == list(__snake_case							)
			for split in result:
				assert result[split].name == expected[split].name
				assert result[split].num_examples == expected[split].num_examples
				assert is_apercent_close(result[split].num_bytes ,expected[split].num_bytes							)
		else:
			result == expected



