
"""simple docstring"""




from typing import List, Optional, Tuple

from tokenizers import pre_tokenizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_clip import CLIPTokenizer


snake_case    =		logging.get_logger(__name__)

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

snake_case    =		{
    'vocab_file': {
        'openai/clip-vit-base-patch32': 'https://huggingface.co/openai/clip-vit-base-patch32/resolve/main/vocab.json',
    },
    'merges_file': {
        'openai/clip-vit-base-patch32': 'https://huggingface.co/openai/clip-vit-base-patch32/resolve/main/merges.txt',
    },
    'tokenizer_file': {
        'openai/clip-vit-base-patch32': (
            'https://huggingface.co/openai/clip-vit-base-patch32/resolve/main/tokenizer.json'
        ),
    },
}

snake_case    =		{
    'openai/clip-vit-base-patch32': 7_7,
}




class      UpperCamelCase	(       __magic_name__      ):

				"""simple docstring"""



				UpperCAmelCase_				:      List[Any]						  =				VOCAB_FILES_NAMES
				UpperCAmelCase_				:      Union[str, Any]						  =				PRETRAINED_VOCAB_FILES_MAP
				UpperCAmelCase_				:      str						  =				PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
				UpperCAmelCase_				:      str						  =				["input_ids", "attention_mask"]
				UpperCAmelCase_				:      Optional[Any]						  =				CLIPTokenizer


				def __init__(				self		,	lowercase__=None		,	lowercase__=None		,	lowercase__=None		,	lowercase__="<|endoftext|>"		,	lowercase__="<|startoftext|>"		,	lowercase__="<|endoftext|>"		,	lowercase__="<|endoftext|>"		,	**lowercase__		,	)    ->    Union[str, Any]:
									"""simple docstring"""







									super().__init__(
									    lowercase__		,	lowercase__		,	tokenizer_file=lowercase__		,	unk_token=lowercase__		,	bos_token=lowercase__		,	eos_token=lowercase__		,	pad_token=lowercase__		,	**lowercase__		,	)

									if not isinstance(self.backend_tokenizer.pre_tokenizer		,	pre_tokenizers.Sequence			):
														raise ValueError(
														    'The `backend_tokenizer` provided does not match the expected format. The CLIP tokenizer has been'
														    ' heavily modified from transformers version 4.17.0. You need to convert the tokenizer you are using'
														    ' to be compatible with this version.The easiest way to do so is'
														    ' `CLIPTokenizerFast.from_pretrained("path_to_local_folder_or_hub_repo, from_slow=True)`. If you want'
														    ' to use your existing tokenizer, you will have to revert to a version prior to 4.17.0 of'
														    ' transformers.'			)

									self._wrap_decode_method_backend_tokenizer()


				def 							A					(				self			)    ->    Tuple:
									"""simple docstring"""







									SCREAMING_SNAKE_CASE				=	self.backend_tokenizer.decode

									def new_decode_method(*lowercase__		,	**lowercase__			):
														SCREAMING_SNAKE_CASE				=	orig_decode_method(*lowercase__		,	**lowercase__			)
														SCREAMING_SNAKE_CASE				=	text.replace(self.backend_tokenizer.model.end_of_word_suffix		,	' '			).strip()
														return text

									SCREAMING_SNAKE_CASE				=	new_decode_method


				def 							A					(				self		,	lowercase__		,	lowercase__ = None			)    ->    List[int]:
									"""simple docstring"""







									SCREAMING_SNAKE_CASE				=	[self.bos_token_id]
									SCREAMING_SNAKE_CASE				=	[self.eos_token_id]

									if token_ids_a is None:
														return bos_token + token_ids_a + eos_token
									return bos_token + token_ids_a + eos_token + eos_token + token_ids_a + eos_token


				def 							A					(				self		,	lowercase__		,	lowercase__ = None			)    ->    List[int]:
									"""simple docstring"""







									SCREAMING_SNAKE_CASE				=	[self.bos_token_id]
									SCREAMING_SNAKE_CASE				=	[self.eos_token_id]

									if token_ids_a is None:
														return len(bos_token + token_ids_a + eos_token			) * [0]
									return len(bos_token + token_ids_a + eos_token + eos_token + token_ids_a + eos_token			) * [0]




				def 							A					(				self		,	lowercase__		,	lowercase__ = None			)    ->    Tuple[str]:
									"""simple docstring"""







									SCREAMING_SNAKE_CASE				=	self._tokenizer.model.save(lowercase__		,	name=lowercase__			)
									return tuple(lowercase__			)







import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_layoutlm import LayoutLMTokenizer


UpperCamelCase__          =logging.get_logger(__name__)

UpperCamelCase__          ={'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer.json'}

UpperCamelCase__          ={
    'vocab_file': {
        'microsoft/layoutlm-base-uncased': (
            'https://huggingface.co/microsoft/layoutlm-base-uncased/resolve/main/vocab.txt'
        ),
        'microsoft/layoutlm-large-uncased': (
            'https://huggingface.co/microsoft/layoutlm-large-uncased/resolve/main/vocab.txt'
        ),
    },
    'tokenizer_file': {
        'microsoft/layoutlm-base-uncased': (
            'https://huggingface.co/microsoft/layoutlm-base-uncased/resolve/main/tokenizer.json'
        ),
        'microsoft/layoutlm-large-uncased': (
            'https://huggingface.co/microsoft/layoutlm-large-uncased/resolve/main/tokenizer.json'
        ),
    },
}

UpperCamelCase__          ={
    'microsoft/layoutlm-base-uncased': 512,
    'microsoft/layoutlm-large-uncased': 512,
}

UpperCamelCase__          ={
    'microsoft/layoutlm-base-uncased': {'do_lower_case': True},
    'microsoft/layoutlm-large-uncased': {'do_lower_case': True},
}





class 	lowerCAmelCase__(       __lowercase			):






       '''simple docstring'''


       __snake_case       	=			VOCAB_FILES_NAMES
       __snake_case       	=			PRETRAINED_VOCAB_FILES_MAP
       __snake_case       	=			PRETRAINED_INIT_CONFIGURATION
       __snake_case       	=			PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
       __snake_case       	=			LayoutLMTokenizer




       def __init__(					self			,  __lowerCamelCase=None			,  __lowerCamelCase=None			,  __lowerCamelCase=True			,  __lowerCamelCase="[UNK]"			,  __lowerCamelCase="[SEP]"			,  __lowerCamelCase="[PAD]"			,  __lowerCamelCase="[CLS]"			,  __lowerCamelCase="[MASK]"			,  __lowerCamelCase=True			,  __lowerCamelCase=None			,  **__lowerCamelCase			,  )	->   Dict:
            super().__init__(
                __lowerCamelCase			,  tokenizer_file=__lowerCamelCase			,  do_lower_case=__lowerCamelCase			,  unk_token=__lowerCamelCase			,  sep_token=__lowerCamelCase			,  pad_token=__lowerCamelCase			,  cls_token=__lowerCamelCase			,  mask_token=__lowerCamelCase			,  tokenize_chinese_chars=__lowerCamelCase			,  strip_accents=__lowerCamelCase			,  **__lowerCamelCase			,  )

            _SCREAMING_SNAKE_CASE				:		int  			=							json.loads(self.backend_tokenizer.normalizer.__getstate__()							)
            if (
                normalizer_state.get("lowercase"			,  __lowerCamelCase							) != do_lower_case
                or normalizer_state.get("strip_accents"			,  __lowerCamelCase							) != strip_accents
                or normalizer_state.get("handle_chinese_chars"			,  __lowerCamelCase							) != tokenize_chinese_chars
            ):
                 _SCREAMING_SNAKE_CASE				:		List[Any]  			=							getattr(__lowerCamelCase			,  normalizer_state.pop("type"							)							)
                 _SCREAMING_SNAKE_CASE				:		str  			=							do_lower_case
                 _SCREAMING_SNAKE_CASE				:		int  			=							strip_accents
                 _SCREAMING_SNAKE_CASE				:		List[Any]  			=							tokenize_chinese_chars
                 _SCREAMING_SNAKE_CASE				:		List[str]  			=							normalizer_class(**__lowerCamelCase							)

            _SCREAMING_SNAKE_CASE				:		List[Any]  			=							do_lower_case




       def 			UpperCamelCase_	(					self			,  __lowerCamelCase			,  __lowerCamelCase=None							)	->   Tuple:
            _SCREAMING_SNAKE_CASE				:		List[str]  			=							[self.cls_token_id] + token_ids_a + [self.sep_token_id]

            if token_ids_a:
                 output += token_ids_a + [self.sep_token_id]

            return output




       def 			UpperCamelCase_	(					self			,  __lowerCamelCase			,  __lowerCamelCase = None							)	->   List[int]:
            _SCREAMING_SNAKE_CASE				:		Any  			=							[self.sep_token_id]
            _SCREAMING_SNAKE_CASE				:		str  			=							[self.cls_token_id]
            if token_ids_a is None:
                 return len(cls + token_ids_a + sep							) * [0]
            return len(cls + token_ids_a + sep							) * [0] + len(token_ids_a + sep							) * [1]







       def 			UpperCamelCase_	(					self			,  __lowerCamelCase			,  __lowerCamelCase = None							)	->   Tuple[str]:
            _SCREAMING_SNAKE_CASE				:		int  			=							self._tokenizer.model.save(__lowerCamelCase			,  name=__lowerCamelCase							)
            return tuple(__lowerCamelCase							)