





"""simple docstring"""






from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


A			      =	logging.get_logger(__name__)

A			      =	{
    '''shi-labs/dinat-mini-in1k-224''': '''https://huggingface.co/shi-labs/dinat-mini-in1k-224/resolve/main/config.json''',
    # See all Dinat models at https://huggingface.co/models?filter=dinat
}




class 					__lowercase      (      _UpperCamelCase ,   _UpperCamelCase				):







					'''simple docstring'''




					__lowerCAmelCase	=	'''dinat'''

					__lowerCAmelCase	=	{
					    '''num_attention_heads''': '''num_heads''',
					    '''num_hidden_layers''': '''num_layers''',
					}







					def __init__(    self						,      _UpperCAmelCase=4						,      _UpperCAmelCase=3						,      _UpperCAmelCase=64						,      _UpperCAmelCase=[3, 4, 6, 5]						,      _UpperCAmelCase=[2, 4, 8, 16]						,      _UpperCAmelCase=7						,      _UpperCAmelCase=[[1, 8, 1], [1, 4, 1, 4], [1, 2, 1, 2, 1, 2], [1, 1, 1, 1, 1]]						,      _UpperCAmelCase=3.0						,      _UpperCAmelCase=True						,      _UpperCAmelCase=0.0						,      _UpperCAmelCase=0.0						,      _UpperCAmelCase=0.1						,      _UpperCAmelCase="gelu"						,      _UpperCAmelCase=0.0_2						,      _UpperCAmelCase=1e-5						,      _UpperCAmelCase=0.0						,      _UpperCAmelCase=None						,      _UpperCAmelCase=None						,      **_UpperCAmelCase						,      ):
									super().__init__(**_UpperCAmelCase  )

									__a			:    Union[str, Any]      							=	patch_size
									__a			:    Union[str, Any]      							=	num_channels
									__a			:    str      							=	embed_dim
									__a			:    Dict      							=	depths
									__a			:    Union[str, Any]      							=	len(_UpperCAmelCase  )
									__a			:    List[Any]      							=	num_heads
									__a			:    List[str]      							=	kernel_size
									__a			:    List[Any]      							=	dilations
									__a			:    int      							=	mlp_ratio
									__a			:    Optional[int]      							=	qkv_bias
									__a			:    Optional[int]      							=	hidden_dropout_prob
									__a			:    str      							=	attention_probs_dropout_prob
									__a			:    Optional[Any]      							=	drop_path_rate
									__a			:    List[str]      							=	hidden_act
									__a			:    Union[str, Any]      							=	layer_norm_eps
									__a			:    Any      							=	initializer_range
									# we set the hidden_size attribute in order to make Dinat work with VisionEncoderDecoderModel
									# this indicates the channel dimension after the last stage of the model
									__a			:    List[str]      							=	int(embed_dim * 2 ** (len(_UpperCAmelCase  ) - 1)  )
									__a			:    Optional[Any]      							=	layer_scale_init_value
									__a			:    Optional[Any]      							=	['''stem'''] + [f"""stage{idx}""" for idx in range(1						,      len(_UpperCAmelCase  ) + 1  )]
									__a							,    __a			:    Any      							=	get_aligned_output_features_output_indices(
									    out_features=_UpperCAmelCase						,      out_indices=_UpperCAmelCase						,      stage_names=self.stage_names  )


"""simple docstring"""





import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_distilbert import DistilBertTokenizer


__UpperCamelCase    : List[Any]				 =						logging.get_logger(__name__)

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

__UpperCamelCase    : List[Any]				 =						{
    '''vocab_file''': {
        '''distilbert-base-uncased''': '''https://huggingface.co/distilbert-base-uncased/resolve/main/vocab.txt''',
        '''distilbert-base-uncased-distilled-squad''': (
            '''https://huggingface.co/distilbert-base-uncased-distilled-squad/resolve/main/vocab.txt'''
        ),
        '''distilbert-base-cased''': '''https://huggingface.co/distilbert-base-cased/resolve/main/vocab.txt''',
        '''distilbert-base-cased-distilled-squad''': (
            '''https://huggingface.co/distilbert-base-cased-distilled-squad/resolve/main/vocab.txt'''
        ),
        '''distilbert-base-german-cased''': '''https://huggingface.co/distilbert-base-german-cased/resolve/main/vocab.txt''',
        '''distilbert-base-multilingual-cased''': (
            '''https://huggingface.co/distilbert-base-multilingual-cased/resolve/main/vocab.txt'''
        ),
    },
    '''tokenizer_file''': {
        '''distilbert-base-uncased''': '''https://huggingface.co/distilbert-base-uncased/resolve/main/tokenizer.json''',
        '''distilbert-base-uncased-distilled-squad''': (
            '''https://huggingface.co/distilbert-base-uncased-distilled-squad/resolve/main/tokenizer.json'''
        ),
        '''distilbert-base-cased''': '''https://huggingface.co/distilbert-base-cased/resolve/main/tokenizer.json''',
        '''distilbert-base-cased-distilled-squad''': (
            '''https://huggingface.co/distilbert-base-cased-distilled-squad/resolve/main/tokenizer.json'''
        ),
        '''distilbert-base-german-cased''': (
            '''https://huggingface.co/distilbert-base-german-cased/resolve/main/tokenizer.json'''
        ),
        '''distilbert-base-multilingual-cased''': (
            '''https://huggingface.co/distilbert-base-multilingual-cased/resolve/main/tokenizer.json'''
        ),
    },
}

__UpperCamelCase    : Union[str, Any]				 =						{
    '''distilbert-base-uncased''': 5_1_2,
    '''distilbert-base-uncased-distilled-squad''': 5_1_2,
    '''distilbert-base-cased''': 5_1_2,
    '''distilbert-base-cased-distilled-squad''': 5_1_2,
    '''distilbert-base-german-cased''': 5_1_2,
    '''distilbert-base-multilingual-cased''': 5_1_2,
}


__UpperCamelCase    : int				 =						{
    '''distilbert-base-uncased''': {'''do_lower_case''': True},
    '''distilbert-base-uncased-distilled-squad''': {'''do_lower_case''': True},
    '''distilbert-base-cased''': {'''do_lower_case''': False},
    '''distilbert-base-cased-distilled-squad''': {'''do_lower_case''': False},
    '''distilbert-base-german-cased''': {'''do_lower_case''': False},
    '''distilbert-base-multilingual-cased''': {'''do_lower_case''': False},
}







class 							SCREAMING_SNAKE_CASE   (						a_			):






					"""simple docstring"""



					lowercase__												=			VOCAB_FILES_NAMES
					lowercase__												=			PRETRAINED_VOCAB_FILES_MAP
					lowercase__												=			PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
					lowercase__												=			PRETRAINED_INIT_CONFIGURATION
					lowercase__												=			["input_ids", "attention_mask"]
					lowercase__												=			DistilBertTokenizer







					def __init__(			self     :							int  ,lowercase_     :							List[str]=None  ,lowercase_     :							int=None  ,lowercase_     :							str=True  ,lowercase_     :							Union[str, Any]="[UNK]"  ,lowercase_     :							List[str]="[SEP]"  ,lowercase_     :							List[str]="[PAD]"  ,lowercase_     :							List[str]="[CLS]"  ,lowercase_     :							List[str]="[MASK]"  ,lowercase_     :							Tuple=True  ,lowercase_     :							Tuple=None  ,**lowercase_     :							str  ,):
						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_  ,)

						lowerCAmelCase__      :		Tuple    							=      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
						):
							lowerCAmelCase__      :		Union[str, Any]    							=      getattr(lowercase_  ,normalizer_state.pop('''type'''						)						)
							lowerCAmelCase__      :		Optional[int]    							=      do_lower_case
							lowerCAmelCase__      :		List[str]    							=      strip_accents
							lowerCAmelCase__      :		int    							=      tokenize_chinese_chars
							lowerCAmelCase__      :		Dict    							=      normalizer_class(**lowercase_						)

						lowerCAmelCase__      :		Tuple    							=      do_lower_case







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




