

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


UpperCAmelCase_							:					Optional[int]		 =   logging.get_logger(__name__)

UpperCAmelCase_							:					Optional[int]		 =   {
    '''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_      (	_lowercase	):
	_lowercase		:   Optional[Any]     					=				'''funnel'''
	_lowercase		:   Tuple     					=				{
	    '''hidden_size''': '''d_model''',
	    '''num_attention_heads''': '''n_head''',
	}




	def __init__(     self						:     Union[str, Any]					,      __A						:     List[Any]=3_0522					,      __A						:     List[str]=[4, 4, 4]					,      __A						:     Optional[int]=None					,      __A						:     List[str]=2					,      __A						:     Optional[Any]=768					,      __A						:     int=12					,      __A						:     List[Any]=64					,      __A						:     Optional[Any]=3072					,      __A						:     str="gelu_new"					,      __A						:     Optional[Any]=0.1					,      __A						:     Optional[int]=0.1					,      __A						:     List[Any]=0.0					,      __A						:     List[str]=0.1					,      __A						:     Union[str, Any]=None					,      __A						:     Tuple=1e-9					,      __A						:     Optional[Any]="mean"					,      __A						:     Optional[int]="relative_shift"					,      __A						:     List[str]=True					,      __A						:     Union[str, Any]=True					,      __A						:     Union[str, Any]=True					,      **__A						:     Tuple					,      ):
		__A :			Tuple		    =			vocab_size
		__A :			Tuple		    =			block_sizes
		__A :			Optional[int]		    =			[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."
		__A :			Tuple		    =			num_decoder_layers
		__A :			Optional[int]		    =			d_model
		__A :			Union[str, Any]		    =			n_head
		__A :			Dict		    =			d_head
		__A :			List[str]		    =			d_inner
		__A :			Optional[Any]		    =			hidden_act
		__A :			Union[str, Any]		    =			hidden_dropout
		__A :			Tuple		    =			attention_dropout
		__A :			Optional[int]		    =			activation_dropout
		__A :			Optional[Any]		    =			initializer_range
		__A :			int		    =			initializer_std
		__A :			List[str]		    =			layer_norm_eps
		assert pooling_type in [
		    "mean",
		    "max",
		], F"""Got {pooling_type} for `pooling_type` but only 'mean' and 'max' are supported."""
		__A :			List[str]		    =			pooling_type
		assert attention_type in [
		    "relative_shift",
		    "factorized",
		], F"""Got {attention_type} for `attention_type` but only 'relative_shift' and 'factorized' are supported."""
		__A :			int		    =			attention_type
		__A :			str		    =			separate_cls
		__A :			List[Any]		    =			truncate_seq
		__A :			List[str]		    =			pool_q_only

		super().__init__(**__A							)




	@property
	def        lowerCAmelCase_       (     self						:     Dict							):
		return sum(self.block_sizes							)




	@num_hidden_layers.setter
	def        lowerCAmelCase_       (     self						:     Optional[Any]					,      __A						:     str							):
		raise NotImplementedError(
		    """This model does not support the setting of `num_hidden_layers`. Please set `block_sizes`."""							)




	@property
	def        lowerCAmelCase_       (     self						:     Optional[Any]							):
		return len(self.block_sizes							)




	@num_blocks.setter
	def        lowerCAmelCase_       (     self						:     List[Any]					,      __A						:     List[Any]							):
		raise NotImplementedError("""This model does not support the setting of `num_blocks`. Please set `block_sizes`."""							)








from sympy import diff, lambdify, symbols
from sympy.functions import *  # noqa: F403
def 							__SCREAMING_SNAKE_CASE     (   a__    :   str			,a__    :   complex			,a__    :   str = "x"			,a__    :   float = 10**-10			,a__    :   int = 1			,)					->				complex:
	__A :			Tuple		    =			symbols(a__       )
	__A :			List[str]		    =			lambdify(a__			,a__       )
	__A :			Any		    =			lambdify(a__			,diff(a__			,a__       )       )

	__A :			Dict		    =			starting_point

	while True:
		if diff_function(a__       ) != 0:
			__A :			Optional[int]		    =			prev_guess - multiplicity * func(a__       ) / diff_function(
			    a__       )
		else:
			raise ZeroDivisionError("""Could not find root"""       ) from None

		# Precision is checked by comparing the difference of consecutive guesses
		if abs(next_guess - prev_guess       ) < precision:
			return next_guess

		__A :			List[Any]		    =			next_guess


# Let's Execute
if __name__ == "__main__":
			# Find root of trigonometric function
			# Find value of pi
			print(f"""The root of sin(x) = 0 is {newton_raphson("sin(x)", 2)}""")

			# Find root of polynomial
			# Find fourth Root of 5
			print(f"""The root of x**4 - 5 = 0 is {newton_raphson("x**4 -5", 0.4 +5J)}""")

			# Find value of e
			print(
			    '''The root of log(y) - 1 = 0 is ''',
			    f"""{newton_raphson("log(y) - 1", 2, variable="y")}""",
			)

			# Exponential Roots
			print(
			    '''The root of exp(x) - 1 = 0 is''',
			    f"""{newton_raphson("exp(x) - 1", 10, precision=0.005)}""",
			)

			# Find root of cos(x)
			print(f"""The root of cos(x) = 0 is {newton_raphson("cos(x)", 0)}""")





