



from __future__ import annotations



def 			_lowerCAmelCase       (					__lowerCAmelCase      )   ->					float:


				"""simple docstring"""

				snake_case__	:      Tuple     		=	0.00
				snake_case__	:      Any     		=	0
				for resistor in resistors:
								if resistor <= 0:
												snake_case__	:      Optional[int]     		=	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 			_lowerCAmelCase       (					__lowerCAmelCase      )   ->					float:


				"""simple docstring"""

				snake_case__	:      str     		=	0.00
				snake_case__	:      Union[str, Any]     		=	0
				for resistor in resistors:
								sum_r += resistor
								if resistor < 0:
												snake_case__	:      List[Any]     		=	f"""Resistor at index {index} has a negative value!"""
												raise ValueError(__lowerCAmelCase      )
								index += 1
				return sum_r


if __name__ == "__main__":
				import doctest

				doctest.testmod()






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__								=						logging.get_logger(__name__)

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

A__								=						{
    '''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__								=						{
    '''google/realm-cc-news-pretrained-embedder''': 512,
    '''google/realm-cc-news-pretrained-encoder''': 512,
    '''google/realm-cc-news-pretrained-scorer''': 512,
    '''google/realm-cc-news-pretrained-openqa''': 512,
    '''google/realm-orqa-nq-openqa''': 512,
    '''google/realm-orqa-nq-reader''': 512,
    '''google/realm-orqa-wq-openqa''': 512,
    '''google/realm-orqa-wq-reader''': 512,
}

A__								=						{
    '''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       a							(			__lowerCamelCase				):
		__lowerCAmelCase	:    List[Any]											=					VOCAB_FILES_NAMES
		__lowerCAmelCase	:    Optional[Any]											=					PRETRAINED_VOCAB_FILES_MAP
		__lowerCAmelCase	:    Optional[Any]											=					PRETRAINED_INIT_CONFIGURATION
		__lowerCAmelCase	:    Optional[Any]											=					PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
		__lowerCAmelCase	:    Optional[Any]											=					RealmTokenizer



		def __init__(     self     :Optional[Any]   ,__lowercase     :Dict=None   ,__lowercase     :Optional[int]=None   ,__lowercase     :Optional[Any]=True   ,__lowercase     :Optional[int]="[UNK]"   ,__lowercase     :List[str]="[SEP]"   ,__lowercase     :List[str]="[PAD]"   ,__lowercase     :int="[CLS]"   ,__lowercase     :str="[MASK]"   ,__lowercase     :Dict=True   ,__lowercase     :List[str]=None   ,**__lowercase     :Any   ,):
						super().__init__(
						    __lowercase   ,tokenizer_file=__lowercase   ,do_lower_case=__lowercase   ,unk_token=__lowercase   ,sep_token=__lowercase   ,pad_token=__lowercase   ,cls_token=__lowercase   ,mask_token=__lowercase   ,tokenize_chinese_chars=__lowercase   ,strip_accents=__lowercase   ,**__lowercase   ,)

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

						snake_case__	:      Tuple     		=	do_lower_case



		def 	__lowerCamelCase			(     self     :Union[str, Any]   ,__lowercase     :Union[str, Any]   ,**__lowercase     :Any  ):
						snake_case__	:      Dict     		=	PaddingStrategy.MAX_LENGTH

						snake_case__	:      List[str]     		=	text
						snake_case__	:      int     		=	kwargs.pop('''text_pair'''   ,__lowercase  )
						snake_case__	:      Optional[int]     		=	kwargs.pop('''return_tensors'''   ,__lowercase  )

						snake_case__	:      str     		=	{
						    '''input_ids''': [],
						    '''attention_mask''': [],
						    '''token_type_ids''': [],
						}

						for idx, candidate_text in enumerate(__lowercase  ):
										if batch_text_pair is not None:
														snake_case__	:      Optional[int]     		=	batch_text_pair[idx]
										else:
														snake_case__	:      Tuple     		=	None

										snake_case__	:      List[str]     		=	super().__call__(__lowercase   ,__lowercase   ,return_tensors=__lowercase   ,**__lowercase  )

										snake_case__	:      Optional[Any]     		=	encoded_candidates.get('''input_ids'''  )
										snake_case__	:      Optional[Any]     		=	encoded_candidates.get('''attention_mask'''  )
										snake_case__	:      List[Any]     		=	encoded_candidates.get('''token_type_ids'''  )

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

						snake_case__	:      Any     		=	{key: item for key, item in output_data.items() if len(__lowercase  ) != 0}

						return BatchEncoding(__lowercase   ,tensor_type=__lowercase  )



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

