



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     __lowerCAmelCase					(    A		):
			UpperCamelCase           =  '''funnel'''
			UpperCamelCase           =  {
			    '''hidden_size''': '''d_model''',
			    '''num_attention_heads''': '''n_head''',
			}



			def __init__(		self     :						Any				,	A     :						Any=3_05_22				,	A     :						Tuple=[4, 4, 4]				,	A     :						Tuple=None				,	A     :						Union[str, Any]=2				,	A     :						int=7_68				,	A     :						Union[str, Any]=12				,	A     :						Any=64				,	A     :						List[str]=30_72				,	A     :						List[str]="gelu_new"				,	A     :						List[str]=0.1				,	A     :						Union[str, Any]=0.1				,	A     :						str=0.0				,	A     :						Union[str, Any]=0.1				,	A     :						Tuple=None				,	A     :						List[str]=1E-9				,	A     :						Union[str, Any]="mean"				,	A     :						List[str]="relative_shift"				,	A     :						Dict=True				,	A     :						List[str]=True				,	A     :						Dict=True				,	**A     :						Tuple				,	)     ->					List[str]:



						"""simple docstring"""






						_UpperCAmelCase	 =     vocab_size
						_UpperCAmelCase	 =     block_sizes
						_UpperCAmelCase	 =     [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."
						_UpperCAmelCase	 =     num_decoder_layers
						_UpperCAmelCase	 =     d_model
						_UpperCAmelCase	 =     n_head
						_UpperCAmelCase	 =     d_head
						_UpperCAmelCase	 =     d_inner
						_UpperCAmelCase	 =     hidden_act
						_UpperCAmelCase	 =     hidden_dropout
						_UpperCAmelCase	 =     attention_dropout
						_UpperCAmelCase	 =     activation_dropout
						_UpperCAmelCase	 =     initializer_range
						_UpperCAmelCase	 =     initializer_std
						_UpperCAmelCase	 =     layer_norm_eps
						assert pooling_type in [
						    "mean",
						    "max",
						], F"Got {pooling_type} for `pooling_type` but only 'mean' and 'max' are supported."
						_UpperCAmelCase	 =     pooling_type
						assert attention_type in [
						    "relative_shift",
						    "factorized",
						], F"Got {attention_type} for `attention_type` but only 'relative_shift' and 'factorized' are supported."
						_UpperCAmelCase	 =     attention_type
						_UpperCAmelCase	 =     separate_cls
						_UpperCAmelCase	 =     truncate_seq
						_UpperCAmelCase	 =     pool_q_only

						super().__init__(**A)



			@property
			def 					_lowerCamelCase (		self     :						str)     ->					Optional[Any]:



						"""simple docstring"""






						return sum(self.block_sizes)



			@num_hidden_layers.setter
			def 					_lowerCamelCase (		self     :						Optional[int]				,	A     :						Dict)     ->					Dict:



						"""simple docstring"""






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



			@property
			def 					_lowerCamelCase (		self     :						Optional[Any])     ->					str:



						"""simple docstring"""






						return len(self.block_sizes)



			@num_blocks.setter
			def 					_lowerCamelCase (		self     :						Union[str, Any]				,	A     :						int)     ->					List[Any]:



						"""simple docstring"""






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





from collections import Counter
from timeit import timeit





def 							A			(  _UpperCAmelCase       :     str = ""							,     )       ->				bool:







			'''simple docstring'''
			return sum(c % 2 for c in Counter(input_str.replace(' '							,     ''					).lower()					).values()					) < 2





def 							A			(  _UpperCAmelCase       :     str = ""					)       ->				bool:







			'''simple docstring'''
			if len(_UpperCAmelCase					) == 0:
						return True
			_UpperCAmelCase	 =     input_str.replace(' '							,     ''					).lower()
			# character_freq_dict: Stores the frequency of every character in the input string
			_UpperCAmelCase	 =     {}

			for character in lower_case_input_str:
						_UpperCAmelCase	 =     character_freq_dict.get(_UpperCAmelCase							,     0					) + 1
			_UpperCAmelCase	 =     0

			for character_count in character_freq_dict.values():
						if character_count % 2:
									odd_char += 1
			if odd_char > 1:
						return False
			return True





def 							A			(  _UpperCAmelCase       :     str = ""					)       ->				None:







			'''simple docstring'''
			print('\nFor string = '							,     _UpperCAmelCase							,     ':'					)
			print(
			    '> can_string_be_rearranged_as_palindrome_counter()'							,     '\tans ='							,     can_string_be_rearranged_as_palindrome_counter(_UpperCAmelCase					)							,     '\ttime ='							,     timeit(
			        'z.can_string_be_rearranged_as_palindrome_counter(z.check_str)'							,     setup='import __main__ as z'							,     )							,     'seconds'							,     )
			print(
			    '> can_string_be_rearranged_as_palindrome()'							,     '\tans ='							,     can_string_be_rearranged_as_palindrome(_UpperCAmelCase					)							,     '\ttime ='							,     timeit(
			        'z.can_string_be_rearranged_as_palindrome(z.check_str)'							,     setup='import __main__ as z'							,     )							,     'seconds'							,     )


if __name__ == "__main__":
							UpperCAmelCase__     = input(
							    "Enter string to determine if it can be rearranged as a palindrome or not: "
							).strip()
							benchmark(check_str)
							UpperCAmelCase__     = can_string_be_rearranged_as_palindrome_counter(check_str)
							print(f"""{check_str} can {"" if status else "not "}be rearranged as a palindrome""")
