




'''simple docstring'''





import json
from typing import List, Optional, Tuple

from tokenizers import pre_tokenizers, processors

from ...tokenization_utils_base import AddedToken, BatchEncoding
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_roberta import RobertaTokenizer


lowerCAmelCase_	:		str			=     logging.get_logger(__name__)

lowerCAmelCase_	:		Optional[Any]			=     {'''vocab_file''': '''vocab.json''', '''merges_file''': '''merges.txt''', '''tokenizer_file''': '''tokenizer.json'''}

lowerCAmelCase_	:		Optional[int]			=     {
    '''vocab_file''': {
        '''roberta-base''': '''https://huggingface.co/roberta-base/resolve/main/vocab.json''',
        '''roberta-large''': '''https://huggingface.co/roberta-large/resolve/main/vocab.json''',
        '''roberta-large-mnli''': '''https://huggingface.co/roberta-large-mnli/resolve/main/vocab.json''',
        '''distilroberta-base''': '''https://huggingface.co/distilroberta-base/resolve/main/vocab.json''',
        '''roberta-base-openai-detector''': '''https://huggingface.co/roberta-base-openai-detector/resolve/main/vocab.json''',
        '''roberta-large-openai-detector''': (
            '''https://huggingface.co/roberta-large-openai-detector/resolve/main/vocab.json'''
        ),
    },
    '''merges_file''': {
        '''roberta-base''': '''https://huggingface.co/roberta-base/resolve/main/merges.txt''',
        '''roberta-large''': '''https://huggingface.co/roberta-large/resolve/main/merges.txt''',
        '''roberta-large-mnli''': '''https://huggingface.co/roberta-large-mnli/resolve/main/merges.txt''',
        '''distilroberta-base''': '''https://huggingface.co/distilroberta-base/resolve/main/merges.txt''',
        '''roberta-base-openai-detector''': '''https://huggingface.co/roberta-base-openai-detector/resolve/main/merges.txt''',
        '''roberta-large-openai-detector''': (
            '''https://huggingface.co/roberta-large-openai-detector/resolve/main/merges.txt'''
        ),
    },
    '''tokenizer_file''': {
        '''roberta-base''': '''https://huggingface.co/roberta-base/resolve/main/tokenizer.json''',
        '''roberta-large''': '''https://huggingface.co/roberta-large/resolve/main/tokenizer.json''',
        '''roberta-large-mnli''': '''https://huggingface.co/roberta-large-mnli/resolve/main/tokenizer.json''',
        '''distilroberta-base''': '''https://huggingface.co/distilroberta-base/resolve/main/tokenizer.json''',
        '''roberta-base-openai-detector''': (
            '''https://huggingface.co/roberta-base-openai-detector/resolve/main/tokenizer.json'''
        ),
        '''roberta-large-openai-detector''': (
            '''https://huggingface.co/roberta-large-openai-detector/resolve/main/tokenizer.json'''
        ),
    },
}

lowerCAmelCase_	:		str			=     {
    '''roberta-base''': 512,
    '''roberta-large''': 512,
    '''roberta-large-mnli''': 512,
    '''distilroberta-base''': 512,
    '''roberta-base-openai-detector''': 512,
    '''roberta-large-openai-detector''': 512,
}




class 		SCREAMING_SNAKE_CASE     (					UpperCamelCase__	):







				'''simple docstring'''
				UpperCAmelCase__							=							VOCAB_FILES_NAMES
				UpperCAmelCase__							=							PRETRAINED_VOCAB_FILES_MAP
				UpperCAmelCase__							=							PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
				UpperCAmelCase__							=							["""input_ids""", """attention_mask"""]
				UpperCAmelCase__							=							RobertaTokenizer





				def __init__(						self					:						int       ,		lowercase__					:						str=None       ,		lowercase__					:						Any=None       ,		lowercase__					:						List[str]=None       ,		lowercase__					:						List[str]="replace"       ,		lowercase__					:						Tuple="<s>"       ,		lowercase__					:						List[str]="</s>"       ,		lowercase__					:						Union[str, Any]="</s>"       ,		lowercase__					:						Any="<s>"       ,		lowercase__					:						Dict="<unk>"       ,		lowercase__					:						List[Any]="<pad>"       ,		lowercase__					:						Optional[Any]="<mask>"       ,		lowercase__					:						Union[str, Any]=False       ,		lowercase__					:						Any=True       ,		**lowercase__					:						List[str]       ,		)							->Tuple:


										'''simple docstring'''




										super().__init__(
										    lowercase__       ,		lowercase__       ,		tokenizer_file=lowercase__       ,		errors=lowercase__       ,		bos_token=lowercase__       ,		eos_token=lowercase__       ,		sep_token=lowercase__       ,		cls_token=lowercase__       ,		unk_token=lowercase__       ,		pad_token=lowercase__       ,		mask_token=lowercase__       ,		add_prefix_space=lowercase__       ,		trim_offsets=lowercase__       ,		**lowercase__       ,		)

										_UpperCamelCase			:			int   			=						json.loads(self.backend_tokenizer.pre_tokenizer.__getstate__()					)
										if pre_tok_state.get("add_prefix_space"       ,		lowercase__					) != add_prefix_space:
																_UpperCamelCase			:			Optional[int]   			=						getattr(lowercase__       ,		pre_tok_state.pop("type"					)					)
																_UpperCamelCase			:			List[str]   			=						add_prefix_space
																_UpperCamelCase			:			Optional[int]   			=						pre_tok_class(**lowercase__					)

										_UpperCamelCase			:			Dict   			=						add_prefix_space

										_UpperCamelCase			:			str   			=						"post_processor"
										_UpperCamelCase			:			Optional[Any]   			=						getattr(self.backend_tokenizer       ,		lowercase__       ,		lowercase__					)
										if tokenizer_component_instance:
																_UpperCamelCase			:			Dict   			=						json.loads(tokenizer_component_instance.__getstate__()					)

																# The lists 'sep' and 'cls' must be cased in tuples for the object `post_processor_class`
																if "sep" in state:
																						_UpperCamelCase			:			Union[str, Any]   			=						tuple(state["sep"]					)
																if "cls" in state:
																						_UpperCamelCase			:			Tuple   			=						tuple(state["cls"]					)

																_UpperCamelCase			:			Optional[Any]   			=						False

																if state.get("add_prefix_space"       ,		lowercase__					) != add_prefix_space:
																						_UpperCamelCase			:			int   			=						add_prefix_space
																						_UpperCamelCase			:			int   			=						True

																if state.get("trim_offsets"       ,		lowercase__					) != trim_offsets:
																						_UpperCamelCase			:			List[str]   			=						trim_offsets
																						_UpperCamelCase			:			Any   			=						True

																if changes_to_apply:
																						_UpperCamelCase			:			Optional[Any]   			=						getattr(lowercase__       ,		state.pop("type"					)					)
																						_UpperCamelCase			:			Optional[Any]   			=						component_class(**lowercase__					)
																						setattr(self.backend_tokenizer       ,		lowercase__       ,		lowercase__					)





				@property
				def  snake_case__				(						self					:						Dict					)							->str:


										'''simple docstring'''




										if self._mask_token is None:
																if self.verbose:
																						logger.error("Using mask_token, but it is not set yet."					)
																return None
										return str(self._mask_token					)





				@mask_token.setter
				def  snake_case__				(						self					:						List[str]       ,		lowercase__					:						List[Any]					)							->int:


										'''simple docstring'''




										_UpperCamelCase			:			List[Any]   			=						AddedToken(lowercase__       ,		lstrip=lowercase__       ,		rstrip=lowercase__					) if isinstance(lowercase__       ,		lowercase__					) else value
										_UpperCamelCase			:			int   			=						value





				def  snake_case__				(						self					:						Optional[int]       ,		*lowercase__					:						Tuple       ,		**lowercase__					:						Optional[Any]					)							->BatchEncoding:


										'''simple docstring'''




										_UpperCamelCase			:			List[Any]   			=						kwargs.get("is_split_into_words"       ,		lowercase__					)
										assert self.add_prefix_space or not is_split_into_words, (
										    f'''You need to instantiate {self.__class__.__name__} with add_prefix_space=True '''
										    "to use it with pretokenized inputs."
										)

										return super()._batch_encode_plus(*lowercase__       ,		**lowercase__					)





				def  snake_case__				(						self					:						List[Any]       ,		*lowercase__					:						List[Any]       ,		**lowercase__					:						List[Any]					)							->BatchEncoding:


										'''simple docstring'''




										_UpperCamelCase			:			Optional[Any]   			=						kwargs.get("is_split_into_words"       ,		lowercase__					)

										assert self.add_prefix_space or not is_split_into_words, (
										    f'''You need to instantiate {self.__class__.__name__} with add_prefix_space=True '''
										    "to use it with pretokenized inputs."
										)

										return super()._encode_plus(*lowercase__       ,		**lowercase__					)





				def  snake_case__				(						self					:						Optional[Any]       ,		lowercase__					:						Union[str, Any]       ,		lowercase__					:						Any = None					)							->Tuple[str]:


										'''simple docstring'''




										_UpperCamelCase			:			List[str]   			=						self._tokenizer.model.save(lowercase__       ,		name=lowercase__					)
										return tuple(lowercase__					)





				def  snake_case__				(						self					:						List[str]       ,		lowercase__					:						Optional[Any]       ,		lowercase__					:						int=None					)							->Dict:


										'''simple docstring'''




										_UpperCamelCase			:			Union[str, Any]   			=						[self.bos_token_id] + token_ids_a + [self.eos_token_id]
										if token_ids_a is None:
																return output

										return output + [self.eos_token_id] + token_ids_a + [self.eos_token_id]







				def  snake_case__				(						self					:						Optional[int]       ,		lowercase__					:						str       ,		lowercase__					:						Any = None					)							->List[int]:


										'''simple docstring'''




										_UpperCamelCase			:			Optional[int]   			=						[self.sep_token_id]
										_UpperCamelCase			:			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 + sep + token_ids_a + sep					) * [0]



'''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_	:		Optional[Any]			=     logging.get_logger(__name__)

lowerCAmelCase_	:		List[Any]			=     {
    """google/efficientnet-b7""": """https://huggingface.co/google/efficientnet-b7/resolve/main/config.json""",
}




class 		SCREAMING_SNAKE_CASE     (					SCREAMING_SNAKE_CASE	):







				'''simple docstring'''
				UpperCAmelCase__							=							'''efficientnet'''





				def __init__(						self					:						Optional[int]       ,		lowercase__					:						int = 3       ,		lowercase__					:						int = 600       ,		lowercase__					:						float = 2.0       ,		lowercase__					:						float = 3.1       ,		lowercase__					:						int = 8       ,		lowercase__					:						List[int] = [3, 3, 5, 3, 5, 5, 3]       ,		lowercase__					:						List[int] = [32, 16, 24, 40, 80, 112, 192]       ,		lowercase__					:						List[int] = [16, 24, 40, 80, 112, 192, 320]       ,		lowercase__					:						List[int] = []       ,		lowercase__					:						List[int] = [1, 2, 2, 2, 1, 2, 1]       ,		lowercase__					:						List[int] = [1, 2, 2, 3, 3, 4, 1]       ,		lowercase__					:						List[int] = [1, 6, 6, 6, 6, 6, 6]       ,		lowercase__					:						float = 0.2_5       ,		lowercase__					:						str = "swish"       ,		lowercase__					:						int = 2_560       ,		lowercase__					:						str = "mean"       ,		lowercase__					:						float = 0.0_2       ,		lowercase__					:						float = 0.0_0_1       ,		lowercase__					:						float = 0.9_9       ,		lowercase__					:						float = 0.5       ,		lowercase__					:						float = 0.2       ,		**lowercase__					:						int       ,		)							->Optional[int]:


										'''simple docstring'''




										super().__init__(**lowercase__					)

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





class 		SCREAMING_SNAKE_CASE     (					SCREAMING_SNAKE_CASE	):







				'''simple docstring'''
				UpperCAmelCase__							=							version.parse('''1.11'''	)





				@property
				def  snake_case__				(						self					:						Union[str, Any]					)							->Mapping[str, Mapping[int, str]]:


										'''simple docstring'''




										return OrderedDict(
										    [
										        ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
										    ]					)







				@property
				def  snake_case__				(						self					:						Any					)							->float:


										'''simple docstring'''




										return 1e-5


