"""simple docstring"""







import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

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


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

_a					:					Dict=			{
    "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"
        ),
    },
}

_a					:					Optional[int]=			{
    "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,
}

_a					:					Union[str, Any]=			{
    "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 		UpperCamelCase      (   lowercase						):
				UpperCAmelCase    :				str   =		VOCAB_FILES_NAMES
				UpperCAmelCase    :				Union[str, Any]   =		PRETRAINED_VOCAB_FILES_MAP
				UpperCAmelCase    :				Union[str, Any]   =		PRETRAINED_INIT_CONFIGURATION
				UpperCAmelCase    :				int   =		PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
				UpperCAmelCase    :				List[Any]   =		ElectraTokenizer



				def __init__(self    :				int     ,  _A    :				int=None     ,  _A    :				str=None     ,  _A    :				Optional[int]=True     ,  _A    :				Optional[int]="[UNK]"     ,  _A    :				List[Any]="[SEP]"     ,  _A    :				str="[PAD]"     ,  _A    :				Union[str, Any]="[CLS]"     ,  _A    :				List[Any]="[MASK]"     ,  _A    :				Optional[Any]=True     ,  _A    :				Any=None     ,  **_A    :				Dict     ,  )   ->     str:
					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     ,  )

					__snake_case      :							Any						=			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
					):
						__snake_case      :							int						=			getattr(_A     ,  normalizer_state.pop('type'))
						__snake_case      :							Optional[int]						=			do_lower_case
						__snake_case      :							List[str]						=			strip_accents
						__snake_case      :							List[Any]						=			tokenize_chinese_chars
						__snake_case      :							Union[str, Any]						=			normalizer_class(**_A)

					__snake_case      :							Optional[int]						=			do_lower_case



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






"""simple docstring"""







import itertools
import string
from collections.abc import Generator, Iterable
def   __UpperCAmelCase    (   UpperCAmelCase_   :    Iterable[str]      ,							UpperCAmelCase_   :    int  )							->      Generator[tuple[str, ...], None, None]:

	'''simple docstring'''





	__snake_case      :							Optional[int]						=			iter(UpperCAmelCase_  )
	while True:
		__snake_case      :							Optional[int]						=			tuple(itertools.islice(UpperCAmelCase_      ,							UpperCAmelCase_  )  )
		if not chunk:
			return
		yield chunk
def   __UpperCAmelCase    (   UpperCAmelCase_   :    str  )							->      str:

	'''simple docstring'''





	__snake_case      :							Any						=			''.join([c.upper() for c in dirty if c in string.ascii_letters]  )
	__snake_case      :							Union[str, Any]						=			''

	if len(UpperCAmelCase_  ) < 2:
		return dirty

	for i in range(len(UpperCAmelCase_  ) - 1  ):
		clean += dirty[i]

		if dirty[i] == dirty[i + 1]:
			clean += "X"

	clean += dirty[-1]

	if len(UpperCAmelCase_  ) & 1:
		clean += "X"

	return clean
def   __UpperCAmelCase    (   UpperCAmelCase_   :    str  )							->      list[str]:

	'''simple docstring'''





	__snake_case      :							List[str]						=			'ABCDEFGHIKLMNOPQRSTUVWXYZ'
	# we're using a list instead of a '2d' array because it makes the math
	# for setting up the table and doing the actual encoding/decoding simpler
	__snake_case      :							Optional[int]						=			[]

	# copy key chars into the table if they are in `alphabet` ignoring duplicates
	for char in key.upper():
		if char not in table and char in alphabet:
			table.append(UpperCAmelCase_  )

    # fill the rest of the table in with the remaining alphabet chars
	for char in alphabet:
		if char not in table:
			table.append(UpperCAmelCase_  )

	return table
def   __UpperCAmelCase    (   UpperCAmelCase_   :    str      ,							UpperCAmelCase_   :    str  )							->      str:

	'''simple docstring'''





	__snake_case      :							str						=			generate_table(UpperCAmelCase_  )
	__snake_case      :							Union[str, Any]						=			prepare_input(UpperCAmelCase_  )
	__snake_case      :							Tuple						=			''

	# https://en.wikipedia.org/wiki/Playfair_cipher#Description
	for chara, chara in chunker(UpperCAmelCase_      ,							2  ):
		__snake_case		,    __snake_case      :							Any						=			divmod(table.index(UpperCAmelCase_  )      ,							5  )
		__snake_case		,    __snake_case      :							Tuple						=			divmod(table.index(UpperCAmelCase_  )      ,							5  )

		if rowa == rowa:
			ciphertext += table[rowa * 5 + (cola + 1) % 5]
			ciphertext += table[rowa * 5 + (cola + 1) % 5]
		elif cola == cola:
			ciphertext += table[((rowa + 1) % 5) * 5 + cola]
			ciphertext += table[((rowa + 1) % 5) * 5 + cola]
		else:  # rectangle
			ciphertext += table[rowa * 5 + cola]
			ciphertext += table[rowa * 5 + cola]

	return ciphertext

def   __UpperCAmelCase    (   UpperCAmelCase_   :    str      ,							UpperCAmelCase_   :    str  )							->      str:

	'''simple docstring'''





	__snake_case      :							Optional[int]						=			generate_table(UpperCAmelCase_  )
	__snake_case      :							Any						=			''

	# https://en.wikipedia.org/wiki/Playfair_cipher#Description
	for chara, chara in chunker(UpperCAmelCase_      ,							2  ):
		__snake_case		,    __snake_case      :							Union[str, Any]						=			divmod(table.index(UpperCAmelCase_  )      ,							5  )
		__snake_case		,    __snake_case      :							Tuple						=			divmod(table.index(UpperCAmelCase_  )      ,							5  )

		if rowa == rowa:
			plaintext += table[rowa * 5 + (cola - 1) % 5]
			plaintext += table[rowa * 5 + (cola - 1) % 5]
		elif cola == cola:
			plaintext += table[((rowa - 1) % 5) * 5 + cola]
			plaintext += table[((rowa - 1) % 5) * 5 + cola]
		else:  # rectangle
			plaintext += table[rowa * 5 + cola]
			plaintext += table[rowa * 5 + cola]

	return plaintext





