





from __future__ import annotations

import typing
from collections.abc import Iterable

import numpy as np

UpperCamelCase__     =	typing.Union[Iterable[float], Iterable[int], np.ndarray]  # noqa: UP007
UpperCamelCase__     =	typing.Union[np.floataa, int, float]  # noqa: UP007





def       _UpperCamelCase       (a__				:Vector				,     a__				:Vector    ):






							"""simple docstring"""





							return np.sqrt(np.sum((np.asarray(a__    ) - np.asarray(a__    )) ** 2    )    )





def       _UpperCamelCase       (a__				:Vector				,     a__				:Vector    ):






							"""simple docstring"""





							return sum((va - va) ** 2 for va, va in zip(a__				,     a__    )    ) ** (1 / 2)


if __name__ == "__main__":





					def       _UpperCamelCase       ():






												"""simple docstring"""





												from timeit import timeit

												print("""Without Numpy"""    )
												print(
												    timeit(
												        """euclidean_distance_no_np([1, 2, 3], [4, 5, 6])"""				,     number=1_0000				,     globals=globals()				,     )    )
												print("""With Numpy"""    )
												print(
												    timeit(
												        """euclidean_distance([1, 2, 3], [4, 5, 6])"""				,     number=1_0000				,     globals=globals()				,     )    )




					benchmark()











import warnings

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


UpperCamelCase__     =	logging.get_logger(__name__)

UpperCamelCase__     =	{
    "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     __SCREAMING_SNAKE_CASE   (       _a    ):
							snake_case       : Any         =    """xlnet"""
							snake_case       : Optional[Any]         =    ["""mems"""]
							snake_case       : Any         =    {
							    """n_token""": """vocab_size""",  # Backward compatibility
							    """hidden_size""": """d_model""",
							    """num_attention_heads""": """n_head""",
							    """num_hidden_layers""": """n_layer""",
							}






							def __init__(  self					,	__lowerCAmelCase=32000					,	__lowerCAmelCase=1024					,	__lowerCAmelCase=24					,	__lowerCAmelCase=16					,	__lowerCAmelCase=4096					,	__lowerCAmelCase="gelu"					,	__lowerCAmelCase=True					,	__lowerCAmelCase="bi"					,	__lowerCAmelCase=0.02					,	__lowerCAmelCase=1E-12					,	__lowerCAmelCase=0.1					,	__lowerCAmelCase=512					,	__lowerCAmelCase=None					,	__lowerCAmelCase=True					,	__lowerCAmelCase=False					,	__lowerCAmelCase=False					,	__lowerCAmelCase=-1					,	__lowerCAmelCase=False					,	__lowerCAmelCase="last"					,	__lowerCAmelCase=True					,	__lowerCAmelCase="tanh"					,	__lowerCAmelCase=0.1					,	__lowerCAmelCase=5					,	__lowerCAmelCase=5					,	__lowerCAmelCase=5					,	__lowerCAmelCase=1					,	__lowerCAmelCase=2					,	**__lowerCAmelCase					,	):
														UpperCamelCase__			       =     vocab_size
														UpperCamelCase__			       =     d_model
														UpperCamelCase__			       =     n_layer
														UpperCamelCase__			       =     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})"""					)
														UpperCamelCase__			       =     d_model // n_head
														UpperCamelCase__			       =     ff_activation
														UpperCamelCase__			       =     d_inner
														UpperCamelCase__			       =     untie_r
														UpperCamelCase__			       =     attn_type

														UpperCamelCase__			       =     initializer_range
														UpperCamelCase__			       =     layer_norm_eps

														UpperCamelCase__			       =     dropout
														UpperCamelCase__			       =     mem_len
														UpperCamelCase__			       =     reuse_len
														UpperCamelCase__			       =     bi_data
														UpperCamelCase__			       =     clamp_len
														UpperCamelCase__			       =     same_length

														UpperCamelCase__			       =     summary_type
														UpperCamelCase__			       =     summary_use_proj
														UpperCamelCase__			       =     summary_activation
														UpperCamelCase__			       =     summary_last_dropout
														UpperCamelCase__			       =     start_n_top
														UpperCamelCase__			       =     end_n_top

														UpperCamelCase__			       =     bos_token_id
														UpperCamelCase__			       =     pad_token_id
														UpperCamelCase__			       =     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."""					,	__lowerCAmelCase					,	)
																					UpperCamelCase__			       =     kwargs["""use_cache"""]

														UpperCamelCase__			       =     use_mems_eval
														UpperCamelCase__			       =     use_mems_train
														super().__init__(pad_token_id=__lowerCAmelCase					,	bos_token_id=__lowerCAmelCase					,	eos_token_id=__lowerCAmelCase					,	**__lowerCAmelCase					)






							@property
							def 			_lowerCamelCase						(  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 			_lowerCamelCase						(  self					,	__lowerCAmelCase					):
														# 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."""					)




