





from __future__ import annotations

class     __SCREAMING_SNAKE_CASE   :






							def __init__(  self					,	__lowerCAmelCase = 0					):
														UpperCamelCase__			       =     key






							def 			_lowerCamelCase						(  self					,	__lowerCAmelCase					,	__lowerCAmelCase					):
														assert isinstance(a_					,	a_					) and isinstance(a_					,	a_					)

														UpperCamelCase__			       =     key or self.__key or 1

														# make sure key is an appropriate size
														key %= 255

														return [chr(ord(a_					) ^ key					) for ch in content]






							def 			_lowerCamelCase						(  self					,	__lowerCAmelCase					,	__lowerCAmelCase					):
														assert isinstance(a_					,	a_					) and isinstance(a_					,	a_					)

														UpperCamelCase__			       =     key or self.__key or 1

														# make sure key is an appropriate size
														key %= 255

														return [chr(ord(a_					) ^ key					) for ch in content]






							def 			_lowerCamelCase						(  self					,	__lowerCAmelCase					,	__lowerCAmelCase = 0					):
														assert isinstance(a_					,	a_					) and isinstance(a_					,	a_					)

														UpperCamelCase__			       =     key or self.__key or 1

														# make sure key can be any size
														while key > 255:
																					key -= 255

														# This will be returned
														UpperCamelCase__			       =     ''''''

														for ch in content:
																					ans += chr(ord(a_					) ^ key					)

														return ans






							def 			_lowerCamelCase						(  self					,	__lowerCAmelCase					,	__lowerCAmelCase = 0					):
														assert isinstance(a_					,	a_					) and isinstance(a_					,	a_					)

														UpperCamelCase__			       =     key or self.__key or 1

														# make sure key can be any size
														while key > 255:
																					key -= 255

														# This will be returned
														UpperCamelCase__			       =     ''''''

														for ch in content:
																					ans += chr(ord(a_					) ^ key					)

														return ans






							def 			_lowerCamelCase						(  self					,	__lowerCAmelCase					,	__lowerCAmelCase = 0					):
														assert isinstance(a_					,	a_					) and isinstance(a_					,	a_					)

														try:
																					with open(a_					) as fin, open("""encrypt.out"""					,	"""w+"""					) as fout:
																												# actual encrypt-process
																												for line in fin:
																																			fout.write(self.encrypt_string(a_					,	a_					)					)

														except OSError:
																					return False

														return True







							def 			_lowerCamelCase						(  self					,	__lowerCAmelCase					,	__lowerCAmelCase					):
														assert isinstance(a_					,	a_					) and isinstance(a_					,	a_					)

														try:
																					with open(a_					) as fin, open("""decrypt.out"""					,	"""w+"""					) as fout:
																												# actual encrypt-process
																												for line in fin:
																																			fout.write(self.decrypt_string(a_					,	a_					)					)

														except OSError:
																					return False

														return True


# Tests
# crypt = XORCipher()
# key = 67

# # test encrypt
# print(crypt.encrypt("hallo welt",key))
# # test decrypt
# print(crypt.decrypt(crypt.encrypt("hallo welt",key), key))

# # test encrypt_string
# print(crypt.encrypt_string("hallo welt",key))

# # test decrypt_string
# print(crypt.decrypt_string(crypt.encrypt_string("hallo welt",key),key))

# if (crypt.encrypt_file("test.txt",key)):
#       print("encrypt successful")
# else:
#       print("encrypt unsuccessful")

# if (crypt.decrypt_file("encrypt.out",key)):
#       print("decrypt successful")
# else:
#       print("decrypt unsuccessful")











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."""					)




