



"""simple docstring"""





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


__lowerCAmelCase							:       int          =       logging.get_logger(__name__)

__lowerCAmelCase							:       Union[str, Any]          =       {
    '''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     (					__UpperCamelCase		):





		"""simple docstring"""






		_lowerCamelCase      	=							'''funnel'''
		_lowerCamelCase      	=							{
		    '''hidden_size''': '''d_model''',
		    '''num_attention_heads''': '''n_head''',
		}





		def __init__(       self				,     _lowercase=3_0_5_2_2				,     _lowercase=[4, 4, 4]				,     _lowercase=None				,     _lowercase=2				,     _lowercase=7_6_8				,     _lowercase=1_2				,     _lowercase=6_4				,     _lowercase=3_0_7_2				,     _lowercase="gelu_new"				,     _lowercase=0.1				,     _lowercase=0.1				,     _lowercase=0.0				,     _lowercase=0.1				,     _lowercase=None				,     _lowercase=1E-9				,     _lowercase="mean"				,     _lowercase="relative_shift"				,     _lowercase=True				,     _lowercase=True				,     _lowercase=True				,     **_lowercase				,     )			->    List[Any]:







								'''simple docstring'''

								snake_case_ :			List[str]            =      vocab_size
								snake_case_ :			Dict            =      block_sizes
								snake_case_ :			Optional[int]            =      [1] * len(__UpperCAmelCase ) if block_repeats is None else block_repeats
								assert len(__UpperCAmelCase ) == len(
								    self.block_repeats ), "`block_sizes` and `block_repeats` should have the same length."
								snake_case_ :			Dict            =      num_decoder_layers
								snake_case_ :			Tuple            =      d_model
								snake_case_ :			List[Any]            =      n_head
								snake_case_ :			Tuple            =      d_head
								snake_case_ :			Union[str, Any]            =      d_inner
								snake_case_ :			Optional[Any]            =      hidden_act
								snake_case_ :			Dict            =      hidden_dropout
								snake_case_ :			Tuple            =      attention_dropout
								snake_case_ :			List[str]            =      activation_dropout
								snake_case_ :			str            =      initializer_range
								snake_case_ :			Optional[Any]            =      initializer_std
								snake_case_ :			Dict            =      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_ :			Optional[int]            =      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_ :			Optional[Any]            =      attention_type
								snake_case_ :			List[Any]            =      separate_cls
								snake_case_ :			List[Any]            =      truncate_seq
								snake_case_ :			List[str]            =      pool_q_only

								super().__init__(**__UpperCAmelCase )





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







								'''simple docstring'''

								return sum(self.block_sizes )





		@num_hidden_layers.setter
		def  UpperCAmelCase__				(       self				,     _lowercase )			->    Union[str, Any]:







								'''simple docstring'''

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





		@property
		def  UpperCAmelCase__				(       self )			->    int:







								'''simple docstring'''

								return len(self.block_sizes )





		@num_blocks.setter
		def  UpperCAmelCase__				(       self				,     _lowercase )			->    Tuple:







								'''simple docstring'''

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









def     a_   (__A      )				->						Dict:



					"""simple docstring"""
					if not head:
										return True
					# split the list to two parts
					__a      ,			__a					:						Any      =					head.next, head
					while fast and fast.next:
										__a					:						Optional[int]      =					fast.next.next
										__a					:						Optional[int]      =					slow.next
					__a					:						Optional[int]      =					slow.next
					__a					:						Tuple      =					None  # Don't forget here! But forget still works!
					# reverse the second part
					__a					:						Any      =					None
					while second:
										__a					:						int      =					second.next
										__a					:						int      =					node
										__a					:						Union[str, Any]      =					second
										__a					:						Union[str, Any]      =					nxt
					# compare two parts
					# second part has the same or one less node
					while node:
										if node.val != head.val:
															return False
										__a					:						int      =					node.next
										__a					:						Dict      =					head.next
					return True







def     a_   (__A      )				->						Union[str, Any]:



					"""simple docstring"""
					if not head or not head.next:
										return True

					# 1. Get the midpoint (slow)
					__a					:						Union[str, Any]      =					head
					while fast and fast.next:
										__a      ,			__a					:						List[str]      =					fast.next.next, slow.next

					# 2. Push the second half into the stack
					__a					:						Dict      =					[slow.val]
					while slow.next:
										__a					:						Optional[Any]      =					slow.next
										stack.append(slow.val      )

					# 3. Comparison
					while stack:
										if stack.pop() != cur.val:
															return False
										__a					:						List[str]      =					cur.next

					return True







def     a_   (__A      )				->						List[str]:



					"""simple docstring"""
					if not head or not head.next:
										return True
					__a					:						Optional[int]      =					{}
					__a					:						Optional[int]      =					0
					while head:
										if head.val in d:
															d[head.val].append(__A      )
										else:
															__a					:						Dict      =					[pos]
										__a					:						Dict      =					head.next
										pos += 1
					__a					:						Dict      =					pos - 1
					__a					:						Optional[int]      =					0
					for v in d.values():
										if len(__A      ) % 2 != 0:
															middle += 1
										else:
															__a					:						Dict      =					0
															for i in range(0				,       len(__A      )      ):
																				if v[i] + v[len(__A      ) - 1 - step] != checksum:
																									return False
																				step += 1
										if middle > 1:
															return False
					return True





