import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from .tokenization_electra import ElectraTokenizer


snake_case      =    {"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"}

snake_case      =    {
    "vocab_file": {
        "google/electra-small-generator": (
            "https://huggingface.co/google/electra-small-generator/resolve/main/vocab.txt"
        ),
        "google/electra-base-generator": "https://huggingface.co/google/electra-base-generator/resolve/main/vocab.txt",
        "google/electra-large-generator": (
            "https://huggingface.co/google/electra-large-generator/resolve/main/vocab.txt"
        ),
        "google/electra-small-discriminator": (
            "https://huggingface.co/google/electra-small-discriminator/resolve/main/vocab.txt"
        ),
        "google/electra-base-discriminator": (
            "https://huggingface.co/google/electra-base-discriminator/resolve/main/vocab.txt"
        ),
        "google/electra-large-discriminator": (
            "https://huggingface.co/google/electra-large-discriminator/resolve/main/vocab.txt"
        ),
    },
    "tokenizer_file": {
        "google/electra-small-generator": (
            "https://huggingface.co/google/electra-small-generator/resolve/main/tokenizer.json"
        ),
        "google/electra-base-generator": (
            "https://huggingface.co/google/electra-base-generator/resolve/main/tokenizer.json"
        ),
        "google/electra-large-generator": (
            "https://huggingface.co/google/electra-large-generator/resolve/main/tokenizer.json"
        ),
        "google/electra-small-discriminator": (
            "https://huggingface.co/google/electra-small-discriminator/resolve/main/tokenizer.json"
        ),
        "google/electra-base-discriminator": (
            "https://huggingface.co/google/electra-base-discriminator/resolve/main/tokenizer.json"
        ),
        "google/electra-large-discriminator": (
            "https://huggingface.co/google/electra-large-discriminator/resolve/main/tokenizer.json"
        ),
    },
}

snake_case      =    {
    "google/electra-small-generator": 512,
    "google/electra-base-generator": 512,
    "google/electra-large-generator": 512,
    "google/electra-small-discriminator": 512,
    "google/electra-base-discriminator": 512,
    "google/electra-large-discriminator": 512,
}

snake_case      =    {
    "google/electra-small-generator": {"do_lower_case": True},
    "google/electra-base-generator": {"do_lower_case": True},
    "google/electra-large-generator": {"do_lower_case": True},
    "google/electra-small-discriminator": {"do_lower_case": True},
    "google/electra-base-discriminator": {"do_lower_case": True},
    "google/electra-large-discriminator": {"do_lower_case": True},
}



class __A     (      A__						):

							'''simple docstring'''

							a_     =					VOCAB_FILES_NAMES
							a_     =					PRETRAINED_VOCAB_FILES_MAP
							a_     =					PRETRAINED_INIT_CONFIGURATION
							a_     =					PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
							a_     =					ElectraTokenizer






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

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

												_lowerCAmelCase			:		str          = do_lower_case






							def 	SCREAMING_SNAKE_CASE__			(				self   ,	_snake_case   ,	_snake_case=None ):
												_lowerCAmelCase			:		Dict          = [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 	SCREAMING_SNAKE_CASE__			(				self   ,	_snake_case   ,	_snake_case = None ):
												_lowerCAmelCase			:		Union[str, Any]          = [self.sep_token_id]
												_lowerCAmelCase			:		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 	SCREAMING_SNAKE_CASE__			(				self   ,	_snake_case   ,	_snake_case = None ):
												_lowerCAmelCase			:		str          = self._tokenizer.model.save(UpperCamelCase_   ,	name=UpperCamelCase_ )
												return tuple(UpperCamelCase_ )










'''simple docstring'''
import os
import unittest

from transformers import LxmertTokenizer, LxmertTokenizerFast
from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers

from ...test_tokenization_common import TokenizerTesterMixin
@require_tokenizers
class   lowercase      (				A__      ,						unittest.TestCase   ):

		"""simple docstring"""

		_a       					=							LxmertTokenizer
		_a       					=							LxmertTokenizerFast
		_a       					=							True
		_a       					=							True




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							super().setUp()

							UpperCamelCase__  :Any				   =					[
							    '''[UNK]''',
							    '''[CLS]''',
							    '''[SEP]''',
							    '''want''',
							    '''##want''',
							    '''##ed''',
							    '''wa''',
							    '''un''',
							    '''runn''',
							    '''##ing''',
							    ''',''',
							    '''low''',
							    '''lowest''',
							]
							UpperCamelCase__  :str				   =					os.path.join(self.tmpdirname       ,  VOCAB_FILES_NAMES['''vocab_file''']				)
							with open(self.vocab_file       ,  '''w'''       ,  encoding='''utf-8'''				) as vocab_writer:
												vocab_writer.write(''''''.join([x + '''\n''' for x in vocab_tokens]				)				)




		def        lowerCAmelCase__							(						self       ,  UpperCamelCase_				):

							'''simple docstring'''


							UpperCamelCase__  :Optional[Any]				   =					'''UNwant\u00E9d,running'''
							UpperCamelCase__  :Union[str, Any]				   =					'''unwanted, running'''
							return input_text, output_text




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :List[Any]				   =					self.tokenizer_class(self.vocab_file				)

							UpperCamelCase__  :List[Any]				   =					tokenizer.tokenize('''UNwant\u00E9d,running'''				)
							self.assertListEqual(UpperCamelCase_       ,  ['''un''', '''##want''', '''##ed''', ''',''', '''runn''', '''##ing''']				)
							self.assertListEqual(tokenizer.convert_tokens_to_ids(UpperCamelCase_				)       ,  [7, 4, 5, 10, 8, 9]				)




		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							if not self.test_rust_tokenizer:
												return

							UpperCamelCase__  :str				   =					self.get_tokenizer()
							UpperCamelCase__  :Union[str, Any]				   =					self.get_rust_tokenizer()

							UpperCamelCase__  :int				   =					'''I was born in 92000, and this is falsé.'''

							UpperCamelCase__  :Optional[Any]				   =					tokenizer.tokenize(UpperCamelCase_				)
							UpperCamelCase__  :str				   =					rust_tokenizer.tokenize(UpperCamelCase_				)
							self.assertListEqual(UpperCamelCase_       ,  UpperCamelCase_				)

							UpperCamelCase__  :Optional[Any]				   =					tokenizer.encode(UpperCamelCase_       ,  add_special_tokens=UpperCamelCase_				)
							UpperCamelCase__  :int				   =					rust_tokenizer.encode(UpperCamelCase_       ,  add_special_tokens=UpperCamelCase_				)
							self.assertListEqual(UpperCamelCase_       ,  UpperCamelCase_				)

							UpperCamelCase__  :Optional[int]				   =					self.get_rust_tokenizer()
							UpperCamelCase__  :Any				   =					tokenizer.encode(UpperCamelCase_				)
							UpperCamelCase__  :Optional[int]				   =					rust_tokenizer.encode(UpperCamelCase_				)
							self.assertListEqual(UpperCamelCase_       ,  UpperCamelCase_				)