




'''simple docstring'''






_lowerCAmelCase				     = {
    '''0000''': '''0''',
    '''0001''': '''1''',
    '''0010''': '''2''',
    '''0011''': '''3''',
    '''0100''': '''4''',
    '''0101''': '''5''',
    '''0110''': '''6''',
    '''0111''': '''7''',
    '''1000''': '''8''',
    '''1001''': '''9''',
    '''1010''': '''a''',
    '''1011''': '''b''',
    '''1100''': '''c''',
    '''1101''': '''d''',
    '''1110''': '''e''',
    '''1111''': '''f''',
}

def       __lowerCAmelCase (   snake_case__						):
			__UpperCamelCase				:      List[str]									=       str(snake_case__						).strip()

			# Exceptions
			if not binary_str:
						raise ValueError("Empty string was passed to the function"						)
			__UpperCamelCase				:      Optional[int]									=       binary_str[0] == """-"""
			__UpperCamelCase				:      Optional[Any]									=       binary_str[1:] if is_negative else binary_str
			if not all(char in "01" for char in binary_str						):
						raise ValueError("Non-binary value was passed to the function"						)

			__UpperCamelCase				:      Optional[int]									=       (
			    """0""" * (4 * (divmod(len(snake_case__						) ,				4						)[0] + 1) - len(snake_case__						)) + binary_str
			)

			__UpperCamelCase				:      Optional[Any]									=       []
			for x in range(0 ,				len(snake_case__						) ,				4						):
						hexadecimal.append(BITS_TO_HEX[binary_str[x : x + 4]]						)
			__UpperCamelCase				:      Tuple									=       """0x""" + """""".join(snake_case__						)

			return "-" + hexadecimal_str if is_negative else hexadecimal_str


if __name__ == "__main__":
				from doctest import testmod

				testmod()









'''simple docstring'''






from typing import Optional, Tuple

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_openai import OpenAIGPTTokenizer


_lowerCAmelCase				     = logging.get_logger(__name__)

_lowerCAmelCase				     = {'''vocab_file''': '''vocab.json''', '''merges_file''': '''merges.txt''', '''tokenizer_file''': '''tokenizer.json'''}

_lowerCAmelCase				     = {
    '''vocab_file''': {'''openai-gpt''': '''https://huggingface.co/openai-gpt/resolve/main/vocab.json'''},
    '''merges_file''': {'''openai-gpt''': '''https://huggingface.co/openai-gpt/resolve/main/merges.txt'''},
    '''tokenizer_file''': {'''openai-gpt''': '''https://huggingface.co/openai-gpt/resolve/main/tokenizer.json'''},
}

_lowerCAmelCase				     = {
    '''openai-gpt''': 512,
}



class  A		(			SCREAMING_SNAKE_CASE__		):




				'''simple docstring'''





				A				     =    VOCAB_FILES_NAMES
				A				     =    PRETRAINED_VOCAB_FILES_MAP
				A				     =    PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
				A				     =    ["input_ids", "attention_mask"]
				A				     =    OpenAIGPTTokenizer
				def __init__(self			,  _UpperCAmelCase=None			,  _UpperCAmelCase=None			,  _UpperCAmelCase=None			,  _UpperCAmelCase="<unk>"			,  **_UpperCAmelCase      )     ->	str:
							super().__init__(_UpperCAmelCase			,  _UpperCAmelCase			,  tokenizer_file=_UpperCAmelCase			,  unk_token=_UpperCAmelCase			,  **_UpperCAmelCase      )
				@property
				def 	a_	(self      )     ->	Dict:
							return True





				def 	a_	(self			,  _UpperCAmelCase			,  _UpperCAmelCase = None      )     ->	Tuple[str]:
							__UpperCamelCase				:      Optional[Any]									=       self._tokenizer.model.save(_UpperCAmelCase			,  name=_UpperCAmelCase      )
							return tuple(_UpperCAmelCase      )



