






import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_base import BatchEncoding
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import PaddingStrategy, logging
from .tokenization_realm import RealmTokenizer


A__			:    Optional[Any]         =				logging.get_logger(__name__)

A__			:    List[str]         =				{'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer.json'}

A__			:    List[Any]         =				{
    'vocab_file': {
        'google/realm-cc-news-pretrained-embedder': (
            'https://huggingface.co/google/realm-cc-news-pretrained-embedder/resolve/main/vocab.txt'
        ),
        'google/realm-cc-news-pretrained-encoder': (
            'https://huggingface.co/google/realm-cc-news-pretrained-encoder/resolve/main/vocab.txt'
        ),
        'google/realm-cc-news-pretrained-scorer': (
            'https://huggingface.co/google/realm-cc-news-pretrained-scorer/resolve/main/vocab.txt'
        ),
        'google/realm-cc-news-pretrained-openqa': (
            'https://huggingface.co/google/realm-cc-news-pretrained-openqa/aresolve/main/vocab.txt'
        ),
        'google/realm-orqa-nq-openqa': 'https://huggingface.co/google/realm-orqa-nq-openqa/resolve/main/vocab.txt',
        'google/realm-orqa-nq-reader': 'https://huggingface.co/google/realm-orqa-nq-reader/resolve/main/vocab.txt',
        'google/realm-orqa-wq-openqa': 'https://huggingface.co/google/realm-orqa-wq-openqa/resolve/main/vocab.txt',
        'google/realm-orqa-wq-reader': 'https://huggingface.co/google/realm-orqa-wq-reader/resolve/main/vocab.txt',
    },
    'tokenizer_file': {
        'google/realm-cc-news-pretrained-embedder': (
            'https://huggingface.co/google/realm-cc-news-pretrained-embedder/resolve/main/tokenizer.jsont'
        ),
        'google/realm-cc-news-pretrained-encoder': (
            'https://huggingface.co/google/realm-cc-news-pretrained-encoder/resolve/main/tokenizer.json'
        ),
        'google/realm-cc-news-pretrained-scorer': (
            'https://huggingface.co/google/realm-cc-news-pretrained-scorer/resolve/main/tokenizer.json'
        ),
        'google/realm-cc-news-pretrained-openqa': (
            'https://huggingface.co/google/realm-cc-news-pretrained-openqa/aresolve/main/tokenizer.json'
        ),
        'google/realm-orqa-nq-openqa': (
            'https://huggingface.co/google/realm-orqa-nq-openqa/resolve/main/tokenizer.json'
        ),
        'google/realm-orqa-nq-reader': (
            'https://huggingface.co/google/realm-orqa-nq-reader/resolve/main/tokenizer.json'
        ),
        'google/realm-orqa-wq-openqa': (
            'https://huggingface.co/google/realm-orqa-wq-openqa/resolve/main/tokenizer.json'
        ),
        'google/realm-orqa-wq-reader': (
            'https://huggingface.co/google/realm-orqa-wq-reader/resolve/main/tokenizer.json'
        ),
    },
}

A__			:    List[Any]         =				{
    'google/realm-cc-news-pretrained-embedder': 5_12,
    'google/realm-cc-news-pretrained-encoder': 5_12,
    'google/realm-cc-news-pretrained-scorer': 5_12,
    'google/realm-cc-news-pretrained-openqa': 5_12,
    'google/realm-orqa-nq-openqa': 5_12,
    'google/realm-orqa-nq-reader': 5_12,
    'google/realm-orqa-wq-openqa': 5_12,
    'google/realm-orqa-wq-reader': 5_12,
}

A__			:    Union[str, Any]         =				{
    'google/realm-cc-news-pretrained-embedder': {'do_lower_case': True},
    'google/realm-cc-news-pretrained-encoder': {'do_lower_case': True},
    'google/realm-cc-news-pretrained-scorer': {'do_lower_case': True},
    'google/realm-cc-news-pretrained-openqa': {'do_lower_case': True},
    'google/realm-orqa-nq-openqa': {'do_lower_case': True},
    'google/realm-orqa-nq-reader': {'do_lower_case': True},
    'google/realm-orqa-wq-openqa': {'do_lower_case': True},
    'google/realm-orqa-wq-reader': {'do_lower_case': True},
}
class    _UpperCAmelCase      ( lowercase_			):

				"""simple docstring"""




				lowercase__       							= VOCAB_FILES_NAMES
				lowercase__       							= PRETRAINED_VOCAB_FILES_MAP
				lowercase__       							= PRETRAINED_INIT_CONFIGURATION
				lowercase__       							= PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
				lowercase__       							= RealmTokenizer




				def __init__(  self		:					Any,						lowerCamelCase		:					Optional[int]=None,						lowerCamelCase		:					Union[str, Any]=None,						lowerCamelCase		:					Optional[Any]=True,						lowerCamelCase		:					Dict="[UNK]",						lowerCamelCase		:					Tuple="[SEP]",						lowerCamelCase		:					Union[str, Any]="[PAD]",						lowerCamelCase		:					Optional[int]="[CLS]",						lowerCamelCase		:					Tuple="[MASK]",						lowerCamelCase		:					int=True,						lowerCamelCase		:					Union[str, Any]=None,						**lowerCamelCase		:					int,						):

								'''simple docstring'''
								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_,						)

								lowercase__     				=    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
								):
												lowercase__     				=    getattr(lowerCamelCase_,						normalizer_state.pop('''type'''						)						)
												lowercase__     				=    do_lower_case
												lowercase__     				=    strip_accents
												lowercase__     				=    tokenize_chinese_chars
												lowercase__     				=    normalizer_class(**lowerCamelCase_						)

								lowercase__     				=    do_lower_case




				def        lowercase__     (  self		:					Any,						lowerCamelCase		:					Any,						**lowerCamelCase		:					int						):

								'''simple docstring'''
								lowercase__     				=    PaddingStrategy.MAX_LENGTH

								lowercase__     				=    text
								lowercase__     				=    kwargs.pop('''text_pair''',						lowerCamelCase_						)
								lowercase__     				=    kwargs.pop('''return_tensors''',						lowerCamelCase_						)

								lowercase__     				=    {
								    """input_ids""": [],
								    """attention_mask""": [],
								    """token_type_ids""": [],
								}

								for idx, candidate_text in enumerate(lowerCamelCase_						):
												if batch_text_pair is not None:
																lowercase__     				=    batch_text_pair[idx]
												else:
																lowercase__     				=    None

												lowercase__     				=    super().__call__(lowerCamelCase_,						lowerCamelCase_,						return_tensors=lowerCamelCase_,						**lowerCamelCase_						)

												lowercase__     				=    encoded_candidates.get('''input_ids'''						)
												lowercase__     				=    encoded_candidates.get('''attention_mask'''						)
												lowercase__     				=    encoded_candidates.get('''token_type_ids'''						)

												if encoded_input_ids is not None:
																output_data["input_ids"].append(lowerCamelCase_						)
												if encoded_attention_mask is not None:
																output_data["attention_mask"].append(lowerCamelCase_						)
												if encoded_token_type_ids is not None:
																output_data["token_type_ids"].append(lowerCamelCase_						)

								lowercase__     				=    {key: item for key, item in output_data.items() if len(lowerCamelCase_						) != 0}

								return BatchEncoding(lowerCamelCase_,						tensor_type=lowerCamelCase_						)




				def        lowercase__     (  self		:					List[Any],						lowerCamelCase		:					Any,						lowerCamelCase		:					Tuple=None						):

								'''simple docstring'''
								lowercase__     				=    [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		:					str,						lowerCamelCase		:					List[int],						lowerCamelCase		:					Optional[List[int]] = None						):

								'''simple docstring'''
								lowercase__     				=    [self.sep_token_id]
								lowercase__     				=    [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		:					List[Any],						lowerCamelCase		:					str,						lowerCamelCase		:					Optional[str] = None						):

								'''simple docstring'''
								lowercase__     				=    self._tokenizer.model.save(lowerCamelCase_,						name=lowerCamelCase_						)
								return tuple(lowerCamelCase_						)












from __future__ import annotations






def 						a    (		lowerCamelCase_       ):






				'''simple docstring'''
				lowercase__     				=    0.00
				lowercase__     				=    0
				for resistor in resistors:
								if resistor <= 0:
												lowercase__     				=    F"""Resistor at index {index} has a negative or zero value!"""
												raise ValueError(lowerCamelCase_       )
								first_sum += 1 / float(lowerCamelCase_       )
								index += 1
				return 1 / first_sum






def 						a    (		lowerCamelCase_       ):






				'''simple docstring'''
				lowercase__     				=    0.00
				lowercase__     				=    0
				for resistor in resistors:
								sum_r += resistor
								if resistor < 0:
												lowercase__     				=    F"""Resistor at index {index} has a negative value!"""
												raise ValueError(lowerCamelCase_       )
								index += 1
				return sum_r


if __name__ == "__main__":
							import doctest

							doctest.testmod()




