






'''simple docstring'''


from typing import Dict, List, Optional, Tuple

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


lowerCamelCase_					:			int     						=				logging.get_logger(__name__)
class  _SCREAMING_SNAKE_CASE				(		SCREAMING_SNAKE_CASE						):


			'''simple docstring'''





			__a				:				Union[str, Any]         =       ["input_ids", "attention_mask"]






			def __init__( self				:    Union[str, Any]			,   lowercase				:    Optional[int]="[PAD]"			,   lowercase				:    Union[str, Any]="[BOS]"			,   lowercase				:    List[Any]="[EOS]"			,   lowercase				:    List[Any]="[MASK]"			,   lowercase				:    Optional[Any]="[CLS]"			,   lowercase				:    Optional[int]="[SEP]"			,   lowercase				:    Optional[Any]=2_0_4_8			,   **lowercase				:    Optional[int]			,   )				->     None:

									'''simple docstring'''







									UpperCamelCase__       =			AddedToken(lowercase			,   lstrip=lowercase			,   rstrip=lowercase      ) if isinstance(lowercase			,   lowercase      ) else pad_token
									UpperCamelCase__       =			AddedToken(lowercase			,   lstrip=lowercase			,   rstrip=lowercase      ) if isinstance(lowercase			,   lowercase      ) else bos_token
									UpperCamelCase__       =			AddedToken(lowercase			,   lstrip=lowercase			,   rstrip=lowercase      ) if isinstance(lowercase			,   lowercase      ) else eos_token
									UpperCamelCase__       =			AddedToken(lowercase			,   lstrip=lowercase			,   rstrip=lowercase      ) if isinstance(lowercase			,   lowercase      ) else mask_token
									UpperCamelCase__       =			AddedToken(lowercase			,   lstrip=lowercase			,   rstrip=lowercase      ) if isinstance(lowercase			,   lowercase      ) else cls_token
									UpperCamelCase__       =			AddedToken(lowercase			,   lstrip=lowercase			,   rstrip=lowercase      ) if isinstance(lowercase			,   lowercase      ) else sep_token

									super().__init__(
									    pad_token=lowercase			,   bos_token=lowercase			,   eos_token=lowercase			,   mask_token=lowercase			,   cls_token=lowercase			,   sep_token=lowercase			,   model_max_length=lowercase			,   **lowercase			,   )

									UpperCamelCase__       =			2**8  # utf is 8 bits

									# define special tokens dict
									UpperCamelCase__       =			{
									    self.pad_token: 0,
									    self.bos_token: 1,
									    self.eos_token: 2,
									    self.mask_token: 3,
									    self.cls_token: 4,
									    self.sep_token: 5,
									}
									UpperCamelCase__       =			len(self.special_tokens_encoder      )
									UpperCamelCase__       =			{v: k for k, v in self.special_tokens_encoder.items()}






			def 					A   ( self				:    Dict      )				->     Dict[str, int]:

									'''simple docstring'''







									UpperCamelCase__       =			self.special_tokens_encoder.copy()
									vocab.update(self.added_tokens_encoder      )
									for i in range(self._utf_vocab_size      ):
															UpperCamelCase__       =			chr(lowercase      )
															UpperCamelCase__       =			i + len(self.special_tokens_encoder      )
									return vocab






			@property
			def 					A   ( self				:    str      )				->     Tuple:

									'''simple docstring'''







									return self._utf_vocab_size + self._num_special_tokens






			def 					A   ( self				:    Any			,   lowercase				:    List[int]			,   lowercase				:    Optional[List[int]] = None			,   lowercase				:    bool = False      )				->     List[int]:

									'''simple docstring'''







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

									# normal case: some special tokens
									if token_ids_a is None:
															return [1] + [0] * len(lowercase      ) + [1]
									return [1] + ([0] * len(lowercase      )) + [1] + ([0] * len(lowercase      )) + [1]






			def 					A   ( self				:    int			,   lowercase				:    List[int]			,   lowercase				:    Optional[List[int]] = None      )				->     List[int]:

									'''simple docstring'''







									if token_ids_a is None:
															return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
									else:
															return [self.cls_token_id] + token_ids_a + [self.sep_token_id] + token_ids_a + [self.sep_token_id]






			def 					A   ( self				:    Dict			,   lowercase				:    str      )				->     List[str]:

									'''simple docstring'''







									UpperCamelCase__       =			[chr(lowercase      ) for i in text.encode("""utf-8"""      )]
									return tokens






			def 					A   ( self				:    Optional[int]			,   lowercase				:    Tuple      )				->     int:

									'''simple docstring'''







									if token in self.special_tokens_encoder:
															UpperCamelCase__       =			self.special_tokens_encoder[token]
									elif token in self.added_tokens_encoder:
															UpperCamelCase__       =			self.added_tokens_encoder[token]
									elif len(lowercase      ) != 1:
															UpperCamelCase__       =			self.unk_token_id
									else:
															UpperCamelCase__       =			ord(lowercase      ) + self._num_special_tokens
									return token_id






			def 					A   ( self				:    List[str]			,   lowercase				:    int      )				->     Dict:

									'''simple docstring'''







									if index in self.special_tokens_decoder:
															UpperCamelCase__       =			self.special_tokens_decoder[index]
									elif index in self.added_tokens_decoder:
															UpperCamelCase__       =			self.added_tokens_decoder[index]
									else:
															UpperCamelCase__       =			chr(index - self._num_special_tokens      )
									return token






			def 					A   ( self				:    Union[str, Any]			,   lowercase				:    Dict      )				->     Optional[Any]:

									'''simple docstring'''







									UpperCamelCase__       =			b""""""
									for token in tokens:
															if token in self.special_tokens_decoder:
																					UpperCamelCase__       =			self.special_tokens_decoder[token].encode("""utf-8"""      )
															elif token in self.added_tokens_decoder:
																					UpperCamelCase__       =			self.special_tokens_decoder[token].encode("""utf-8"""      )
															elif token in self.special_tokens_encoder:
																					UpperCamelCase__       =			token.encode("""utf-8"""      )
															elif token in self.added_tokens_encoder:
																					UpperCamelCase__       =			token.encode("""utf-8"""      )
															else:
																					UpperCamelCase__       =			bytes([ord(lowercase      )]      )
															bstring += tok_string
									UpperCamelCase__       =			bstring.decode("""utf-8"""			,   errors="""replace"""      )
									return string







			def 					A   ( self				:    Tuple			,   lowercase				:    str			,   lowercase				:    Optional[str] = None      )				->     Tuple[str]:

									'''simple docstring'''







									return ()








'''simple docstring'''


from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


lowerCamelCase_					:			Any     						=				{
    '''configuration_sam''': [
        '''SAM_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''SamConfig''',
        '''SamMaskDecoderConfig''',
        '''SamPromptEncoderConfig''',
        '''SamVisionConfig''',
    ],
    '''processing_sam''': ['''SamProcessor'''],
}


try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowerCamelCase_					:			Union[str, Any]     						=				[
					    '''SAM_PRETRAINED_MODEL_ARCHIVE_LIST''',
					    '''SamModel''',
					    '''SamPreTrainedModel''',
					]
try:
					if not is_tf_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowerCamelCase_					:			Optional[Any]     						=				[
					    '''TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST''',
					    '''TFSamModel''',
					    '''TFSamPreTrainedModel''',
					]
try:
					if not is_vision_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowerCamelCase_					:			Optional[Any]     						=				['''SamImageProcessor''']


if TYPE_CHECKING:
					from .configuration_sam import (
					    SAM_PRETRAINED_CONFIG_ARCHIVE_MAP,
					    SamConfig,
					    SamMaskDecoderConfig,
					    SamPromptEncoderConfig,
					    SamVisionConfig,
					)
					from .processing_sam import SamProcessor

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_sam import SAM_PRETRAINED_MODEL_ARCHIVE_LIST, SamModel, SamPreTrainedModel

					try:
										if not is_tf_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_tf_sam import TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST, TFSamModel, TFSamPreTrainedModel

					try:
										if not is_vision_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .image_processing_sam import SamImageProcessor

else:
					import sys

					lowerCamelCase_					:			Optional[Any]     						=				_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)
