





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:
				__lowercase							:Optional[int]							=	None

__lowercase							:str							=	logging.get_logger(__name__)

__lowercase							:str							=	{"vocab_file": "spm.model", "tokenizer_file": "tokenizer.json"}

__lowercase							:Optional[int]							=	{
    "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"
        ),
    }
}

__lowercase							:Union[str, Any]							=	{
    "microsoft/deberta-v2-xlarge": 512,
    "microsoft/deberta-v2-xxlarge": 512,
    "microsoft/deberta-v2-xlarge-mnli": 512,
    "microsoft/deberta-v2-xxlarge-mnli": 512,
}

__lowercase							:int							=	{
    "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  (					lowercase__				):






							"""simple docstring"""

							snake_case_							=    VOCAB_FILES_NAMES
							snake_case_							=    PRETRAINED_VOCAB_FILES_MAP
							snake_case_							=    PRETRAINED_INIT_CONFIGURATION
							snake_case_							=    PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
							snake_case_							=    DebertaVaTokenizer

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

													SCREAMING_SNAKE_CASE__  :					Tuple =       do_lower_case
													SCREAMING_SNAKE_CASE__  :					Any =       split_by_punct
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       vocab_file
													SCREAMING_SNAKE_CASE__  :					Any =       False if not self.vocab_file else True

							def   A_	(   self					:  List[Any]				,						a					:  Union[str, Any]				,						a					:  Optional[Any]=None     )						->List[Any]:

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

							def   A_	(   self					:  List[Any]				,						a					:  Union[str, Any]				,						a					:  Tuple=None				,						a					:  Tuple=False     )						->Tuple:

													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   A_	(   self					:  str				,						a					:  Union[str, Any]				,						a					:  Optional[Any]=None     )						->str:
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       [self.sep_token_id]
													SCREAMING_SNAKE_CASE__  :					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					:  int				,						a					:  str				,						a					:  Optional[str] = None     )						->Tuple[str]:
													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
													SCREAMING_SNAKE_CASE__  :					str =       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,)






import copy

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


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

__lowercase							:Optional[Any]							=	{
    "facebook/sam-vit-huge": "https://huggingface.co/facebook/sam-vit-huge/resolve/main/config.json",
    "facebook/sam-vit-large": "https://huggingface.co/facebook/sam-vit-large/resolve/main/config.json",
    "facebook/sam-vit-base": "https://huggingface.co/facebook/sam-vit-base/resolve/main/config.json",
}



class  _a  (					lowercase__				):






							"""simple docstring"""

							def __init__(   self					:  List[Any]				,						a					:  int=2_56				,						a					:  Tuple=10_24				,						a					:  Optional[Any]=16				,						a					:  Dict=16				,						a					:  str=4				,						a					:  Union[str, Any]="gelu"				,						a					:  Optional[Any]=1E-6				,						**a					:  Dict				,						)						->Union[str, Any]:
													super().__init__(**a     )
													SCREAMING_SNAKE_CASE__  :					Any =       hidden_size
													SCREAMING_SNAKE_CASE__  :					List[Any] =       image_size
													SCREAMING_SNAKE_CASE__  :					List[str] =       patch_size
													SCREAMING_SNAKE_CASE__  :					str =       image_size // patch_size
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       mask_input_channels
													SCREAMING_SNAKE_CASE__  :					Any =       num_point_embeddings
													SCREAMING_SNAKE_CASE__  :					str =       hidden_act
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       layer_norm_eps







class  _a  (					lowercase__				):






							"""simple docstring"""

							def __init__(   self					:  Union[str, Any]				,						a					:  Optional[int]=2_56				,						a					:  Dict="relu"				,						a					:  Dict=20_48				,						a					:  Union[str, Any]=2				,						a					:  str=8				,						a					:  str=2				,						a					:  List[Any]=3				,						a					:  str=3				,						a					:  List[str]=2_56				,						a					:  str=1E-6				,						**a					:  Optional[int]				,						)						->Dict:
													super().__init__(**a     )
													SCREAMING_SNAKE_CASE__  :					List[Any] =       hidden_size
													SCREAMING_SNAKE_CASE__  :					List[Any] =       hidden_act
													SCREAMING_SNAKE_CASE__  :					Dict =       mlp_dim
													SCREAMING_SNAKE_CASE__  :					List[Any] =       num_hidden_layers
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       num_attention_heads
													SCREAMING_SNAKE_CASE__  :					List[Any] =       attention_downsample_rate
													SCREAMING_SNAKE_CASE__  :					List[str] =       num_multimask_outputs
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       iou_head_depth
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       iou_head_hidden_dim
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       layer_norm_eps







class  _a  (					lowercase__				):






							"""simple docstring"""

							def __init__(   self					:  Tuple				,						a					:  str=7_68				,						a					:  Tuple=2_56				,						a					:  Tuple=12				,						a					:  List[str]=12				,						a					:  Optional[Any]=3				,						a					:  str=10_24				,						a					:  str=16				,						a					:  Union[str, Any]="gelu"				,						a					:  Optional[int]=1E-06				,						a					:  Optional[Any]=0.0				,						a					:  str=1E-10				,						a					:  Optional[int]=True				,						a					:  Dict=4.0				,						a					:  Optional[Any]=True				,						a					:  List[str]=True				,						a					:  str=14				,						a					:  List[str]=[2, 5, 8, 11]				,						a					:  int=1_28				,						a					:  int=None				,						**a					:  List[str]				,						)						->Union[str, Any]:
													super().__init__(**a     )

													SCREAMING_SNAKE_CASE__  :					Tuple =       hidden_size
													SCREAMING_SNAKE_CASE__  :					List[Any] =       output_channels
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       num_hidden_layers
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       num_attention_heads
													SCREAMING_SNAKE_CASE__  :					List[str] =       num_channels
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       image_size
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       patch_size
													SCREAMING_SNAKE_CASE__  :					List[str] =       hidden_act
													SCREAMING_SNAKE_CASE__  :					str =       layer_norm_eps
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       attention_dropout
													SCREAMING_SNAKE_CASE__  :					List[Any] =       initializer_range
													SCREAMING_SNAKE_CASE__  :					Tuple =       qkv_bias
													SCREAMING_SNAKE_CASE__  :					Tuple =       mlp_ratio
													SCREAMING_SNAKE_CASE__  :					Tuple =       use_abs_pos
													SCREAMING_SNAKE_CASE__  :					Dict =       use_rel_pos
													SCREAMING_SNAKE_CASE__  :					Tuple =       window_size
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       global_attn_indexes
													SCREAMING_SNAKE_CASE__  :					Any =       num_pos_feats
													SCREAMING_SNAKE_CASE__  :					int =       int(hidden_size * mlp_ratio     ) if mlp_dim is None else mlp_dim







class  _a  (					lowercase__				):






							"""simple docstring"""

							snake_case_							=    "sam"
							snake_case_							=    True

							def __init__(   self					:  str				,						a					:  Optional[int]=None				,						a					:  Any=None				,						a					:  Any=None				,						a					:  str=0.02				,						**a					:  int				,						)						->Optional[int]:
													super().__init__(**a     )
													SCREAMING_SNAKE_CASE__  :					Dict =       vision_config if vision_config is not None else {}
													SCREAMING_SNAKE_CASE__  :					str =       prompt_encoder_config if prompt_encoder_config is not None else {}
													SCREAMING_SNAKE_CASE__  :					Tuple =       mask_decoder_config if mask_decoder_config is not None else {}

													if isinstance(a				,						a     ):
																			SCREAMING_SNAKE_CASE__  :					Tuple =       vision_config.to_dict()
													if isinstance(a				,						a     ):
																			SCREAMING_SNAKE_CASE__  :					Dict =       prompt_encoder_config.to_dict()
													if isinstance(a				,						a     ):
																			SCREAMING_SNAKE_CASE__  :					List[Any] =       mask_decoder_config.to_dict()

													SCREAMING_SNAKE_CASE__  :					str =       SamVisionConfig(**a     )
													SCREAMING_SNAKE_CASE__  :					str =       SamPromptEncoderConfig(**a     )
													SCREAMING_SNAKE_CASE__  :					int =       SamMaskDecoderConfig(**a     )
													SCREAMING_SNAKE_CASE__  :					List[str] =       initializer_range






							def   A_	(   self					:  str     )						->Dict:
													SCREAMING_SNAKE_CASE__  :					int =       copy.deepcopy(self.__dict__     )
													SCREAMING_SNAKE_CASE__  :					str =       self.vision_config.to_dict()
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       self.prompt_encoder_config.to_dict()
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       self.mask_decoder_config.to_dict()
													SCREAMING_SNAKE_CASE__  :					Tuple =       self.__class__.model_type
													return output