






"""simple docstring"""





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


__lowerCamelCase							=  logging.get_logger(__name__)

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

__lowerCamelCase							=  {
    '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'
        ),
    },
}

__lowerCamelCase							=  {
    '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,
}

__lowerCamelCase							=  {
    '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		(   SCREAMING_SNAKE_CASE_			):
					UpperCAmelCase__								=				VOCAB_FILES_NAMES
					UpperCAmelCase__								=				PRETRAINED_VOCAB_FILES_MAP
					UpperCAmelCase__								=				PRETRAINED_INIT_CONFIGURATION
					UpperCAmelCase__								=				PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
					UpperCAmelCase__								=				RealmTokenizer

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

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

											__magic_name__:	List[Any]							=       do_lower_case

					def   lowerCamelCase__   (			self  :      str     ,		__snake_case  :      int     ,		**__snake_case  :      Union[str, Any]					)			->							Union[str, Any]:
											__magic_name__:	Any							=       PaddingStrategy.MAX_LENGTH

											__magic_name__:	Union[str, Any]							=       text
											__magic_name__:	int							=       kwargs.pop("""text_pair"""     ,		__snake_case					)
											__magic_name__:	Optional[Any]							=       kwargs.pop("""return_tensors"""     ,		__snake_case					)

											__magic_name__:	str							=       {
											    """input_ids""": [],
											    """attention_mask""": [],
											    """token_type_ids""": [],
											}

											for idx, candidate_text in enumerate(__snake_case					):
																	if batch_text_pair is not None:
																							__magic_name__:	Dict							=       batch_text_pair[idx]
																	else:
																							__magic_name__:	Optional[Any]							=       None

																	__magic_name__:	Dict							=       super().__call__(__snake_case     ,		__snake_case     ,		return_tensors=__snake_case     ,		**__snake_case					)

																	__magic_name__:	Dict							=       encoded_candidates.get("""input_ids"""					)
																	__magic_name__:	List[Any]							=       encoded_candidates.get("""attention_mask"""					)
																	__magic_name__:	int							=       encoded_candidates.get("""token_type_ids"""					)

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

											__magic_name__:	str							=       {key: item for key, item in output_data.items() if len(__snake_case					) != 0}

											return BatchEncoding(__snake_case     ,		tensor_type=__snake_case					)

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











"""simple docstring"""





from collections import OrderedDict
from typing import List, Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


__lowerCamelCase							=  logging.get_logger(__name__)

__lowerCamelCase							=  {
    'google/efficientnet-b7': 'https://huggingface.co/google/efficientnet-b7/resolve/main/config.json',
}



class       __A		(   SCREAMING_SNAKE_CASE_			):
					UpperCAmelCase__								=				"efficientnet"

					def __init__(			self  :      Optional[Any]     ,		__snake_case  :      int = 3     ,		__snake_case  :      int = 6_0_0     ,		__snake_case  :      float = 2.0     ,		__snake_case  :      float = 3.1     ,		__snake_case  :      int = 8     ,		__snake_case  :      List[int] = [3, 3, 5, 3, 5, 5, 3]     ,		__snake_case  :      List[int] = [3_2, 1_6, 2_4, 4_0, 8_0, 1_1_2, 1_9_2]     ,		__snake_case  :      List[int] = [1_6, 2_4, 4_0, 8_0, 1_1_2, 1_9_2, 3_2_0]     ,		__snake_case  :      List[int] = []     ,		__snake_case  :      List[int] = [1, 2, 2, 2, 1, 2, 1]     ,		__snake_case  :      List[int] = [1, 2, 2, 3, 3, 4, 1]     ,		__snake_case  :      List[int] = [1, 6, 6, 6, 6, 6, 6]     ,		__snake_case  :      float = 0.25     ,		__snake_case  :      str = "swish"     ,		__snake_case  :      int = 2_5_6_0     ,		__snake_case  :      str = "mean"     ,		__snake_case  :      float = 0.02     ,		__snake_case  :      float = 0.001     ,		__snake_case  :      float = 0.99     ,		__snake_case  :      float = 0.5     ,		__snake_case  :      float = 0.2     ,		**__snake_case  :      List[Any]     ,		)			->							List[Any]:
											super().__init__(**__snake_case					)

											__magic_name__:	str							=       num_channels
											__magic_name__:	List[str]							=       image_size
											__magic_name__:	List[str]							=       width_coefficient
											__magic_name__:	Optional[Any]							=       depth_coefficient
											__magic_name__:	Tuple							=       depth_divisor
											__magic_name__:	Dict							=       kernel_sizes
											__magic_name__:	int							=       in_channels
											__magic_name__:	str							=       out_channels
											__magic_name__:	Dict							=       depthwise_padding
											__magic_name__:	Union[str, Any]							=       strides
											__magic_name__:	Dict							=       num_block_repeats
											__magic_name__:	Tuple							=       expand_ratios
											__magic_name__:	List[str]							=       squeeze_expansion_ratio
											__magic_name__:	Any							=       hidden_act
											__magic_name__:	Tuple							=       hidden_dim
											__magic_name__:	int							=       pooling_type
											__magic_name__:	int							=       initializer_range
											__magic_name__:	List[str]							=       batch_norm_eps
											__magic_name__:	str							=       batch_norm_momentum
											__magic_name__:	List[str]							=       dropout_rate
											__magic_name__:	Dict							=       drop_connect_rate
											__magic_name__:	Optional[Any]							=       sum(__snake_case					) * 4



class       __A		(   SCREAMING_SNAKE_CASE_			):
					UpperCAmelCase__								=				version.parse("1.11"			)

					@property
					def   lowerCamelCase__   (			self  :      List[str]					)			->							Mapping[str, Mapping[int, str]]:
											return OrderedDict(
											    [
											        ("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""}),
											    ]					)






					@property
					def   lowerCamelCase__   (			self  :      List[Any]					)			->							float:
											return 1E-5



