





from collections import OrderedDict
from typing import Mapping

from packaging import version

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


__A       :					Union[str, Any]     					=     logging.get_logger(__name__)

__A       :					Dict     					=     {
    "apple/mobilevit-small": "https://huggingface.co/apple/mobilevit-small/resolve/main/config.json",
    "apple/mobilevit-x-small": "https://huggingface.co/apple/mobilevit-x-small/resolve/main/config.json",
    "apple/mobilevit-xx-small": "https://huggingface.co/apple/mobilevit-xx-small/resolve/main/config.json",
    "apple/deeplabv3-mobilevit-small": (
        "https://huggingface.co/apple/deeplabv3-mobilevit-small/resolve/main/config.json"
    ),
    "apple/deeplabv3-mobilevit-x-small": (
        "https://huggingface.co/apple/deeplabv3-mobilevit-x-small/resolve/main/config.json"
    ),
    "apple/deeplabv3-mobilevit-xx-small": (
        "https://huggingface.co/apple/deeplabv3-mobilevit-xx-small/resolve/main/config.json"
    ),
    # See all MobileViT models at https://huggingface.co/models?filter=mobilevit
}

class 			A_ (a_    ):
	UpperCAmelCase__      =    '''mobilevit'''
	def __init__(					self							,      _A=3							,      _A=2_5_6							,      _A=2							,      _A=[1_4_4, 1_9_2, 2_4_0]							,      _A=[1_6, 3_2, 6_4, 9_6, 1_2_8, 1_6_0, 6_4_0]							,      _A=4							,      _A=2.0							,      _A=4.0							,      _A="silu"							,      _A=3							,      _A=3_2							,      _A=0.1							,      _A=0.0							,      _A=0.1							,      _A=0.02							,      _A=1E-5							,      _A=True							,      _A=2_5_6							,      _A=[6, 1_2, 1_8]							,      _A=0.1							,      _A=2_5_5							,      **_A							,      ):






				'''simple docstring'''







				super().__init__(**_A	)

				UpperCAmelCase     	=       num_channels
				UpperCAmelCase     	=       image_size
				UpperCAmelCase     	=       patch_size
				UpperCAmelCase     	=       hidden_sizes
				UpperCAmelCase     	=       neck_hidden_sizes
				UpperCAmelCase     	=       num_attention_heads
				UpperCAmelCase     	=       mlp_ratio
				UpperCAmelCase     	=       expand_ratio
				UpperCAmelCase     	=       hidden_act
				UpperCAmelCase     	=       conv_kernel_size
				UpperCAmelCase     	=       output_stride
				UpperCAmelCase     	=       hidden_dropout_prob
				UpperCAmelCase     	=       attention_probs_dropout_prob
				UpperCAmelCase     	=       classifier_dropout_prob
				UpperCAmelCase     	=       initializer_range
				UpperCAmelCase     	=       layer_norm_eps
				UpperCAmelCase     	=       qkv_bias

				# decode head attributes for semantic segmentation
				UpperCAmelCase     	=       aspp_out_channels
				UpperCAmelCase     	=       atrous_rates
				UpperCAmelCase     	=       aspp_dropout_prob
				UpperCAmelCase     	=       semantic_loss_ignore_index

class 			A_ (a_    ):
	UpperCAmelCase__      =    version.parse('''1.11'''    )
	@property
	def   _lowercase       (					self	):






				'''simple docstring'''







				return OrderedDict([('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''})]	)
	@property
	def   _lowercase       (					self	):






				'''simple docstring'''







				if self.task == "image-classification":
							return OrderedDict([('''logits''', {0: '''batch'''})]	)
				else:
							return OrderedDict([('''last_hidden_state''', {0: '''batch'''}), ('''pooler_output''', {0: '''batch'''})]	)







	@property
	def   _lowercase       (					self	):






				'''simple docstring'''







				return 1E-4










import os
from shutil import copyfile
from typing import Optional, Tuple

from ...file_utils import is_sentencepiece_available
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging


if is_sentencepiece_available():
				from .tokenization_deberta_va import DebertaVaTokenizer
else:
				__A       :					Optional[int]     					=     None

__A       :					Dict     					=     logging.get_logger(__name__)

__A       :					Union[str, Any]     					=     {"vocab_file": "spm.model", "tokenizer_file": "tokenizer.json"}

__A       :					Union[str, Any]     					=     {
    "vocab_file": {
        "microsoft/deberta-v2-xlarge": "https://huggingface.co/microsoft/deberta-v2-xlarge/resolve/main/spm.model",
        "microsoft/deberta-v2-xxlarge": "https://huggingface.co/microsoft/deberta-v2-xxlarge/resolve/main/spm.model",
        "microsoft/deberta-v2-xlarge-mnli": (
            "https://huggingface.co/microsoft/deberta-v2-xlarge-mnli/resolve/main/spm.model"
        ),
        "microsoft/deberta-v2-xxlarge-mnli": (
            "https://huggingface.co/microsoft/deberta-v2-xxlarge-mnli/resolve/main/spm.model"
        ),
    }
}

__A       :					List[Any]     					=     {
    "microsoft/deberta-v2-xlarge": 512,
    "microsoft/deberta-v2-xxlarge": 512,
    "microsoft/deberta-v2-xlarge-mnli": 512,
    "microsoft/deberta-v2-xxlarge-mnli": 512,
}

__A       :					Any     					=     {
    "microsoft/deberta-v2-xlarge": {"do_lower_case": False},
    "microsoft/deberta-v2-xxlarge": {"do_lower_case": False},
    "microsoft/deberta-v2-xlarge-mnli": {"do_lower_case": False},
    "microsoft/deberta-v2-xxlarge-mnli": {"do_lower_case": False},
}

class 			A_ (a_    ):
	UpperCAmelCase__      =    VOCAB_FILES_NAMES
	UpperCAmelCase__      =    PRETRAINED_VOCAB_FILES_MAP
	UpperCAmelCase__      =    PRETRAINED_INIT_CONFIGURATION
	UpperCAmelCase__      =    PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
	UpperCAmelCase__      =    DebertaVaTokenizer
	def __init__(					self							,      _A=None							,      _A=None							,      _A=False							,      _A=False							,      _A="[CLS]"							,      _A="[SEP]"							,      _A="[UNK]"							,      _A="[SEP]"							,      _A="[PAD]"							,      _A="[CLS]"							,      _A="[MASK]"							,      **_A							,      ):






				'''simple docstring'''







				super().__init__(
				    _A							,      tokenizer_file=_A							,      do_lower_case=_A							,      bos_token=_A							,      eos_token=_A							,      unk_token=_A							,      sep_token=_A							,      pad_token=_A							,      cls_token=_A							,      mask_token=_A							,      split_by_punct=_A							,      **_A							,      )

				UpperCAmelCase     	=       do_lower_case
				UpperCAmelCase     	=       split_by_punct
				UpperCAmelCase     	=       vocab_file
				UpperCAmelCase     	=       False if not self.vocab_file else True
	def   _lowercase       (					self							,      _A							,      _A=None	):






				'''simple docstring'''







				if token_ids_a is None:
							return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
				UpperCAmelCase     	=       [self.cls_token_id]
				UpperCAmelCase     	=       [self.sep_token_id]
				return cls + token_ids_a + sep + token_ids_a + sep
	def   _lowercase       (					self							,      _A							,      _A=None							,      _A=False	):






				'''simple docstring'''







				if already_has_special_tokens:
							return super().get_special_tokens_mask(
							    token_ids_a=_A							,      token_ids_a=_A							,      already_has_special_tokens=_A	)

				if token_ids_a is not None:
							return [1] + ([0] * len(_A	)) + [1] + ([0] * len(_A	)) + [1]
				return [1] + ([0] * len(_A	)) + [1]
	def   _lowercase       (					self							,      _A							,      _A=None	):






				'''simple docstring'''







				UpperCAmelCase     	=       [self.sep_token_id]
				UpperCAmelCase     	=       [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							,      _A							,      _A = None	):






				'''simple docstring'''







				if not self.can_save_slow_tokenizer:
							raise ValueError(
							    '''Your fast tokenizer does not have the necessary information to save the vocabulary for a slow '''
							    '''tokenizer.'''	)

				if not os.path.isdir(_A	):
							logger.error(F"""Vocabulary path ({save_directory}) should be a directory"""	)
							return
				UpperCAmelCase     	=       os.path.join(
				    _A							,      (filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''vocab_file''']	)

				if os.path.abspath(self.vocab_file	) != os.path.abspath(_A	):
							copyfile(self.vocab_file							,      _A	)

				return (out_vocab_file,)



