
'''simple docstring'''





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


SCREAMING_SNAKE_CASE							:List[str]											=       logging.get_logger(__name__)

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

SCREAMING_SNAKE_CASE							:int											=       {
    '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'
        ),
    },
}

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

SCREAMING_SNAKE_CASE							:Optional[int]											=       {
    'microsoft/layoutlm-base-uncased': {'do_lower_case': True},
    'microsoft/layoutlm-large-uncased': {'do_lower_case': True},
}





class 							UpperCAmelCase   (						__SCREAMING_SNAKE_CASE						):




	'''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      :				Dict							,A      :				Dict=None							,A      :				Union[str, Any]=None							,A      :				Tuple=True							,A      :				List[Any]="[UNK]"							,A      :				Optional[Any]="[SEP]"							,A      :				Dict="[PAD]"							,A      :				Optional[Any]="[CLS]"							,A      :				Optional[int]="[MASK]"							,A      :				List[str]=True							,A      :				str=None							,**A      :				List[Any]							,):
					super().__init__(
					    A							,tokenizer_file=A							,do_lower_case=A							,unk_token=A							,sep_token=A							,pad_token=A							,cls_token=A							,mask_token=A							,tokenize_chinese_chars=A							,strip_accents=A							,**A							,)

					__A         =				json.loads(self.backend_tokenizer.normalizer.__getstate__()				)
					if (
					    normalizer_state.get("lowercase"							,A				) != do_lower_case
					    or normalizer_state.get("strip_accents"							,A				) != strip_accents
					    or normalizer_state.get("handle_chinese_chars"							,A				) != tokenize_chinese_chars
					):
									__A         =				getattr(A							,normalizer_state.pop("type"				)				)
									__A         =				do_lower_case
									__A         =				strip_accents
									__A         =				tokenize_chinese_chars
									__A         =				normalizer_class(**A				)

					__A         =				do_lower_case






	def        UpperCamelCase_						( self      :				int							,A      :				Optional[int]							,A      :				List[Any]=None				):
					__A         =				[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      :				Tuple							,A      :				List[int]							,A      :				Optional[List[int]] = None				):
					__A         =				[self.sep_token_id]
					__A         =				[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      :				List[Any]							,A      :				str							,A      :				Optional[str] = None				):
					__A         =				self._tokenizer.model.save(A							,name=A				)
					return tuple(A				)


import torch

from transformers import PreTrainedModel

from .custom_configuration import CustomConfig, NoSuperInitConfig





class 							UpperCAmelCase   (						__SCREAMING_SNAKE_CASE						):




	'''simple docstring'''





	snake_case_      					=  CustomConfig






	def __init__( self      :				Optional[int]							,A      :				List[str]				):
					super().__init__(A				)
					__A         =				torch.nn.Linear(config.hidden_size							,config.hidden_size				)






	def        UpperCamelCase_						( self      :				Union[str, Any]							,A      :				Optional[int]				):
					return self.linear(A				)







	def        UpperCamelCase_						( self      :				Optional[int]							,A      :				int				):
					pass





class 							UpperCAmelCase   (						__SCREAMING_SNAKE_CASE						):




	'''simple docstring'''





	snake_case_      					=  NoSuperInitConfig






	def __init__( self      :				Optional[int]							,A      :				Union[str, Any]				):
					super().__init__(A				)
					__A         =				torch.nn.Linear(config.attribute							,config.attribute				)






	def        UpperCamelCase_						( self      :				str							,A      :				Any				):
					return self.linear(A				)







	def        UpperCamelCase_						( self      :				Tuple							,A      :				int				):
					pass
