
from typing import Optional, Tuple

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


snake_case_      :					Union[str, Any]				      =     logging.get_logger(__name__)

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

snake_case_      :					Tuple				      =     {
    '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'},
}

snake_case_      :					str				      =     {
    'openai-gpt': 5_1_2,
}





class 		__lowerCamelCase     (   lowercase		):
							lowerCamelCase__:				List[Any]      =							VOCAB_FILES_NAMES
							lowerCamelCase__:				Optional[Any]      =							PRETRAINED_VOCAB_FILES_MAP
							lowerCamelCase__:				List[Any]      =							PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
							lowerCamelCase__:				Optional[int]      =							['''input_ids''', '''attention_mask''']
							lowerCamelCase__:				Any      =							OpenAIGPTTokenizer



							def __init__(     self	,				__snake_case=None	,				__snake_case=None	,				__snake_case=None	,				__snake_case="<unk>"	,				**__snake_case							)						->     int:






								"""simple docstring"""



								super().__init__(__snake_case	,				__snake_case	,				tokenizer_file=__snake_case	,				unk_token=__snake_case	,				**__snake_case							)



							@property
							def     A__ (     self							)						->     int:






								"""simple docstring"""



								return True




							def     A__ (     self	,				__snake_case	,				__snake_case = None							)						->     Tuple[str]:






								"""simple docstring"""



								UpperCAmelCase:					Any 						=     self._tokenizer.model.save(__snake_case	,				name=__snake_case							)
								return tuple(__snake_case							)


from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding





class 		__lowerCamelCase     (   lowercase		):
							lowerCamelCase__:				Any      =							['''image_processor''', '''tokenizer''']
							lowerCamelCase__:				List[Any]      =							'''EfficientNetImageProcessor'''
							lowerCamelCase__:				str      =							('''BertTokenizer''', '''BertTokenizerFast''')



							def __init__(     self	,				__snake_case	,				__snake_case							)						->     Optional[Any]:






								"""simple docstring"""



								super().__init__(__snake_case	,				__snake_case							)



							def __call__(     self	,				__snake_case=None	,				__snake_case=None	,				__snake_case="max_length"	,				__snake_case=6_4	,				__snake_case=None	,				**__snake_case							)						->     Any:






								"""simple docstring"""



								if text is None and images is None:
									raise ValueError("You have to specify either text or images. Both cannot be none."							)

								if text is not None:
									UpperCAmelCase:					Dict 						=     self.tokenizer(
									    __snake_case	,				padding=__snake_case	,				max_length=__snake_case	,				return_tensors=__snake_case	,				**__snake_case							)

								if images is not None:
									UpperCAmelCase:					List[str] 						=     self.image_processor(__snake_case	,				return_tensors=__snake_case	,				**__snake_case							)

								if text is not None and images is not None:
									UpperCAmelCase:					Optional[int] 						=     image_features.pixel_values
									return encoding
								elif text is not None:
									return encoding
								else:
									return BatchEncoding(data=dict(**__snake_case							)	,				tensor_type=__snake_case							)



							def     A__ (     self	,				*__snake_case	,				**__snake_case							)						->     Any:






								"""simple docstring"""



								return self.tokenizer.batch_decode(*__snake_case	,				**__snake_case							)



							def     A__ (     self	,				*__snake_case	,				**__snake_case							)						->     List[str]:






								"""simple docstring"""



								return self.tokenizer.decode(*__snake_case	,				**__snake_case							)




							@property
							def     A__ (     self							)						->     Optional[int]:






								"""simple docstring"""



								UpperCAmelCase:					Optional[int] 						=     self.tokenizer.model_input_names
								UpperCAmelCase:					int 						=     self.image_processor.model_input_names
								return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names							)							)
