



import warnings

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


_lowercase     							=						logging.get_logger(__name__)

_lowercase     							=						{
    '''xlnet-base-cased''': '''https://huggingface.co/xlnet-base-cased/resolve/main/config.json''',
    '''xlnet-large-cased''': '''https://huggingface.co/xlnet-large-cased/resolve/main/config.json''',
}
class 				__A					( A_      ):
			UpperCamelCase					:str     =			'''xlnet'''
			UpperCamelCase					:str     =			['''mems''']
			UpperCamelCase					:List[str]     =			{
			    '''n_token''': '''vocab_size''',  # Backward compatibility
			    '''hidden_size''': '''d_model''',
			    '''num_attention_heads''': '''n_head''',
			    '''num_hidden_layers''': '''n_layer''',
			}





			def __init__(self							,    __magic_name__=32000							,    __magic_name__=1024							,    __magic_name__=24							,    __magic_name__=16							,    __magic_name__=4096							,    __magic_name__="gelu"							,    __magic_name__=True							,    __magic_name__="bi"							,    __magic_name__=0.02							,    __magic_name__=1E-12							,    __magic_name__=0.1							,    __magic_name__=512							,    __magic_name__=None							,    __magic_name__=True							,    __magic_name__=False							,    __magic_name__=False							,    __magic_name__=-1							,    __magic_name__=False							,    __magic_name__="last"							,    __magic_name__=True							,    __magic_name__="tanh"							,    __magic_name__=0.1							,    __magic_name__=5							,    __magic_name__=5							,    __magic_name__=5							,    __magic_name__=1							,    __magic_name__=2							,    **__magic_name__							,    ):
						lowerCamelCase__ :      Tuple								=		vocab_size
						lowerCamelCase__ :      List[Any]								=		d_model
						lowerCamelCase__ :      List[str]								=		n_layer
						lowerCamelCase__ :      Any								=		n_head
						if d_model % n_head != 0:
									raise ValueError(f"'d_model % n_head' ({d_model % n_head}) should be equal to 0"				)
						if "d_head" in kwargs:
									if kwargs["d_head"] != d_model // n_head:
												raise ValueError(
												    f"`d_head` ({kwargs['d_head']}) should be equal to `d_model // n_head` ({d_model // n_head})"				)
						lowerCamelCase__ :      Optional[int]								=		d_model // n_head
						lowerCamelCase__ :      Union[str, Any]								=		ff_activation
						lowerCamelCase__ :      List[Any]								=		d_inner
						lowerCamelCase__ :      List[Any]								=		untie_r
						lowerCamelCase__ :      List[str]								=		attn_type

						lowerCamelCase__ :      Any								=		initializer_range
						lowerCamelCase__ :      Tuple								=		layer_norm_eps

						lowerCamelCase__ :      Optional[Any]								=		dropout
						lowerCamelCase__ :      Dict								=		mem_len
						lowerCamelCase__ :      Union[str, Any]								=		reuse_len
						lowerCamelCase__ :      Tuple								=		bi_data
						lowerCamelCase__ :      int								=		clamp_len
						lowerCamelCase__ :      Tuple								=		same_length

						lowerCamelCase__ :      Union[str, Any]								=		summary_type
						lowerCamelCase__ :      Union[str, Any]								=		summary_use_proj
						lowerCamelCase__ :      Any								=		summary_activation
						lowerCamelCase__ :      int								=		summary_last_dropout
						lowerCamelCase__ :      Optional[int]								=		start_n_top
						lowerCamelCase__ :      Optional[Any]								=		end_n_top

						lowerCamelCase__ :      Any								=		bos_token_id
						lowerCamelCase__ :      Dict								=		pad_token_id
						lowerCamelCase__ :      Union[str, Any]								=		eos_token_id

						if "use_cache" in kwargs:
									warnings.warn(
									    """The `use_cache` argument is deprecated and will be removed in a future version, use `use_mems_eval`"""
									    """ instead."""							,    __magic_name__							,    )
									lowerCamelCase__ :      Any								=		kwargs["""use_cache"""]

						lowerCamelCase__ :      Dict								=		use_mems_eval
						lowerCamelCase__ :      Tuple								=		use_mems_train
						super().__init__(pad_token_id=__magic_name__							,    bos_token_id=__magic_name__							,    eos_token_id=__magic_name__							,    **__magic_name__				)





			@property
			def        _snake_case    (self				):
						logger.info(f"The model {self.model_type} is one of the few models that has no sequence length limit."				)
						return -1





			@max_position_embeddings.setter
			def        _snake_case    (self							,    __magic_name__				):
						# Message copied from Transformer-XL documentation
						raise NotImplementedError(
						    f"The model {self.model_type} is one of the few models that has no sequence length limit."				)








from math import factorial, pi






def      _A				(UpperCamelCase		:      float      ,			UpperCamelCase		:      int = 30 )  ->float:



			'''simple docstring'''







			if not isinstance(UpperCamelCase      ,			(int, float) ):
						raise ValueError("""maclaurin_sin() requires either an int or float for theta""" )

			if not isinstance(UpperCamelCase      ,			UpperCamelCase ) or accuracy <= 0:
						raise ValueError("""maclaurin_sin() requires a positive int for accuracy""" )

			lowerCamelCase__ :      Dict								=		float(UpperCamelCase )
			lowerCamelCase__ :      int								=		theta // (2 * pi)
			theta -= 2 * div * pi
			return sum(
			    (-1) ** r * theta ** (2 * r + 1) / factorial(2 * r + 1 ) for r in range(UpperCamelCase ) )






def      _A				(UpperCamelCase		:      float      ,			UpperCamelCase		:      int = 30 )  ->float:



			'''simple docstring'''







			if not isinstance(UpperCamelCase      ,			(int, float) ):
						raise ValueError("""maclaurin_cos() requires either an int or float for theta""" )

			if not isinstance(UpperCamelCase      ,			UpperCamelCase ) or accuracy <= 0:
						raise ValueError("""maclaurin_cos() requires a positive int for accuracy""" )

			lowerCamelCase__ :      int								=		float(UpperCamelCase )
			lowerCamelCase__ :      Optional[int]								=		theta // (2 * pi)
			theta -= 2 * div * pi
			return sum((-1) ** r * theta ** (2 * r) / factorial(2 * r ) for r in range(UpperCamelCase ) )


if __name__ == "__main__":
				import doctest

				doctest.testmod()

				print(maclaurin_sin(10))
				print(maclaurin_sin(-10))
				print(maclaurin_sin(10, 15))
				print(maclaurin_sin(-10, 15))

				print(maclaurin_cos(5))
				print(maclaurin_cos(-5))
				print(maclaurin_cos(10, 15))
				print(maclaurin_cos(-10, 15))



