





"""simple docstring"""


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

from ...tokenization_utils import AddedToken
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import is_sentencepiece_available, logging


if is_sentencepiece_available():
		from .tokenization_albert import AlbertTokenizer
else:
		__magic_name__       :					Dict						=			None

__magic_name__       :					Union[str, Any]						=			logging.get_logger(__name__)
__magic_name__       :					int						=			{"""vocab_file""": """spiece.model""", """tokenizer_file""": """tokenizer.json"""}

__magic_name__       :					Optional[int]						=			{
    """vocab_file""": {
        """albert-base-v1""": """https://huggingface.co/albert-base-v1/resolve/main/spiece.model""",
        """albert-large-v1""": """https://huggingface.co/albert-large-v1/resolve/main/spiece.model""",
        """albert-xlarge-v1""": """https://huggingface.co/albert-xlarge-v1/resolve/main/spiece.model""",
        """albert-xxlarge-v1""": """https://huggingface.co/albert-xxlarge-v1/resolve/main/spiece.model""",
        """albert-base-v2""": """https://huggingface.co/albert-base-v2/resolve/main/spiece.model""",
        """albert-large-v2""": """https://huggingface.co/albert-large-v2/resolve/main/spiece.model""",
        """albert-xlarge-v2""": """https://huggingface.co/albert-xlarge-v2/resolve/main/spiece.model""",
        """albert-xxlarge-v2""": """https://huggingface.co/albert-xxlarge-v2/resolve/main/spiece.model""",
    },
    """tokenizer_file""": {
        """albert-base-v1""": """https://huggingface.co/albert-base-v1/resolve/main/tokenizer.json""",
        """albert-large-v1""": """https://huggingface.co/albert-large-v1/resolve/main/tokenizer.json""",
        """albert-xlarge-v1""": """https://huggingface.co/albert-xlarge-v1/resolve/main/tokenizer.json""",
        """albert-xxlarge-v1""": """https://huggingface.co/albert-xxlarge-v1/resolve/main/tokenizer.json""",
        """albert-base-v2""": """https://huggingface.co/albert-base-v2/resolve/main/tokenizer.json""",
        """albert-large-v2""": """https://huggingface.co/albert-large-v2/resolve/main/tokenizer.json""",
        """albert-xlarge-v2""": """https://huggingface.co/albert-xlarge-v2/resolve/main/tokenizer.json""",
        """albert-xxlarge-v2""": """https://huggingface.co/albert-xxlarge-v2/resolve/main/tokenizer.json""",
    },
}

__magic_name__       :					Tuple						=			{
    """albert-base-v1""": 5_1_2,
    """albert-large-v1""": 5_1_2,
    """albert-xlarge-v1""": 5_1_2,
    """albert-xxlarge-v1""": 5_1_2,
    """albert-base-v2""": 5_1_2,
    """albert-large-v2""": 5_1_2,
    """albert-xlarge-v2""": 5_1_2,
    """albert-xxlarge-v2""": 5_1_2,
}

__magic_name__       :					List[Any]						=			"""▁"""






class 							lowercase__			(   __SCREAMING_SNAKE_CASE	):

			"""simple docstring"""
			__lowerCAmelCase     :				Optional[int]										=  VOCAB_FILES_NAMES
			__lowerCAmelCase     :				Optional[int]										=  PRETRAINED_VOCAB_FILES_MAP
			__lowerCAmelCase     :				List[str]										=  PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
			__lowerCAmelCase     :				Optional[int]										=  AlbertTokenizer







			def __init__(      self						,   _A=None						,   _A=None						,   _A=True						,   _A=True						,   _A=False						,   _A="[CLS]"						,   _A="[SEP]"						,   _A="<unk>"						,   _A="[SEP]"						,   _A="<pad>"						,   _A="[CLS]"						,   _A="[MASK]"						,   **_A						,   ):






									'''simple docstring'''







									UpperCamelCase				:		List[str]				   =			(
									    AddedToken(_A						,   lstrip=_A						,   rstrip=_A						,   normalized=_A    )
									    if isinstance(_A						,   _A    )
									    else mask_token
									)

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

									UpperCamelCase				:		Dict				   =			do_lower_case
									UpperCamelCase				:		str				   =			remove_space
									UpperCamelCase				:		List[str]				   =			keep_accents
									UpperCamelCase				:		Optional[int]				   =			vocab_file
									UpperCamelCase				:		Tuple				   =			False if not self.vocab_file else True







			def   _a      (      self						,   _A						,   _A = None    ):






									'''simple docstring'''







									UpperCamelCase				:		Dict				   =			[self.sep_token_id]
									UpperCamelCase				:		Optional[Any]				   =			[self.cls_token_id]
									if token_ids_a is None:
															return cls + token_ids_a + sep
									return cls + token_ids_a + sep + token_ids_a + sep







			def   _a      (      self						,   _A						,   _A = None    ):






									'''simple docstring'''







									UpperCamelCase				:		Tuple				   =			[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    ) * [0] + len(token_ids_a + sep    ) * [1]







			def   _a      (      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				:		List[Any]				   =			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,)










"""simple docstring"""


from ...configuration_utils import PretrainedConfig
from ...utils import logging


__magic_name__       :					Dict						=			logging.get_logger(__name__)

__magic_name__       :					List[str]						=			{
    """microsoft/swinv2-tiny-patch4-window8-256""": (
        """https://huggingface.co/microsoft/swinv2-tiny-patch4-window8-256/resolve/main/config.json"""
    ),
}






class 							lowercase__			(   __SCREAMING_SNAKE_CASE	):

			"""simple docstring"""
			__lowerCAmelCase     :				List[str]										=  """swinv2"""

			__lowerCAmelCase     :				Optional[Any]										=  {
			    """num_attention_heads""": """num_heads""",
			    """num_hidden_layers""": """num_layers""",
			}







			def __init__(      self						,   _A=2_2_4						,   _A=4						,   _A=3						,   _A=9_6						,   _A=[2, 2, 6, 2]						,   _A=[3, 6, 1_2, 2_4]						,   _A=7						,   _A=4.0						,   _A=True						,   _A=0.0						,   _A=0.0						,   _A=0.1						,   _A="gelu"						,   _A=False						,   _A=0.02						,   _A=1e-5						,   _A=3_2						,   **_A						,   ):






									'''simple docstring'''







									super().__init__(**_A    )

									UpperCamelCase				:		Optional[Any]				   =			image_size
									UpperCamelCase				:		Tuple				   =			patch_size
									UpperCamelCase				:		str				   =			num_channels
									UpperCamelCase				:		Dict				   =			embed_dim
									UpperCamelCase				:		List[str]				   =			depths
									UpperCamelCase				:		Optional[Any]				   =			len(_A    )
									UpperCamelCase				:		Optional[int]				   =			num_heads
									UpperCamelCase				:		Optional[int]				   =			window_size
									UpperCamelCase				:		List[Any]				   =			mlp_ratio
									UpperCamelCase				:		str				   =			qkv_bias
									UpperCamelCase				:		str				   =			hidden_dropout_prob
									UpperCamelCase				:		Tuple				   =			attention_probs_dropout_prob
									UpperCamelCase				:		List[Any]				   =			drop_path_rate
									UpperCamelCase				:		str				   =			hidden_act
									UpperCamelCase				:		Optional[Any]				   =			use_absolute_embeddings
									UpperCamelCase				:		Dict				   =			layer_norm_eps
									UpperCamelCase				:		Dict				   =			initializer_range
									UpperCamelCase				:		str				   =			encoder_stride
									# we set the hidden_size attribute in order to make Swinv2 work with VisionEncoderDecoderModel
									# this indicates the channel dimension after the last stage of the model
									UpperCamelCase				:		Any				   =			int(embed_dim * 2 ** (len(_A    ) - 1)    )
									UpperCamelCase				:		str				   =			(0, 0, 0, 0)



