




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


_snake_case            = logging.get_logger(__name__)

_snake_case            = {"openai-gpt": "https://huggingface.co/openai-gpt/resolve/main/config.json"}







class 		lowercase							(     UpperCamelCase__	):
     _a											=		"openai-gpt"
     _a											=		{
         "max_position_embeddings": "n_positions",
         "hidden_size": "n_embd",
         "num_attention_heads": "n_head",
         "num_hidden_layers": "n_layer",
     }

     def __init__(						self	,  _a=4_0478	,  _a=512	,  _a=768	,  _a=12	,  _a=12	,  _a="gelu"	,  _a=0.1	,  _a=0.1	,  _a=0.1	,  _a=1e-5	,  _a=0.02	,  _a="cls_index"	,  _a=True	,  _a=None	,  _a=True	,  _a=0.1	,  **_a	,  )		->							Optional[Any]:
           _A							:  Optional[Any]    =		vocab_size
           _A							:  Optional[int]    =		n_positions
           _A							:  Tuple    =		n_embd
           _A							:  Optional[Any]    =		n_layer
           _A							:  Any    =		n_head
           _A							:  Optional[int]    =		afn
           _A							:  int    =		resid_pdrop
           _A							:  List[Any]    =		embd_pdrop
           _A							:  List[Any]    =		attn_pdrop
           _A							:  int    =		layer_norm_epsilon
           _A							:  Tuple    =		initializer_range
           _A							:  Tuple    =		summary_type
           _A							:  List[Any]    =		summary_use_proj
           _A							:  int    =		summary_activation
           _A							:  int    =		summary_first_dropout
           _A							:  Union[str, Any]    =		summary_proj_to_labels
           super().__init__(**_a       )







from __future__ import annotations







class 		lowercase							:

     def __init__(						self	,  _a = 0       )		->							str:
           _A							:  Any    =		key

     def       a__			(						self	,  _a	,  _a       )		->							list[str]:
           assert isinstance(_a	,  _a       ) and isinstance(_a	,  _a       )

           _A							:  Any    =		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       a__			(						self	,  _a	,  _a       )		->							list[str]:
           assert isinstance(_a	,  _a       ) and isinstance(_a	,  _a       )

           _A							:  List[Any]    =		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       a__			(						self	,  _a	,  _a = 0       )		->							str:
           assert isinstance(_a	,  _a       ) and isinstance(_a	,  _a       )

           _A							:  List[Any]    =		key or self.__key or 1

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

           # This will be returned
           _A							:  List[str]    =		""""""

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

           return ans

     def       a__			(						self	,  _a	,  _a = 0       )		->							str:
           assert isinstance(_a	,  _a       ) and isinstance(_a	,  _a       )

           _A							:  List[str]    =		key or self.__key or 1

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

           # This will be returned
           _A							:  List[str]    =		""""""

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

           return ans

     def       a__			(						self	,  _a	,  _a = 0       )		->							bool:
           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       a__			(						self	,  _a	,  _a       )		->							bool:
           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")

