






"""simple docstring"""



from typing import Dict, List, Optional, Tuple

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


A_     =				logging.get_logger(__name__)






class 				__SCREAMING_SNAKE_CASE    (					UpperCamelCase		):
							snake_case_  =				['input_ids', 'attention_mask']


							def __init__(      self   :    Dict      ,     snake_case   :    List[Any]="[PAD]"      ,     snake_case   :    Optional[Any]="[BOS]"      ,     snake_case   :    Any="[EOS]"      ,     snake_case   :    Tuple="[MASK]"      ,     snake_case   :    Optional[int]="[CLS]"      ,     snake_case   :    Any="[SEP]"      ,     snake_case   :    Optional[Any]=2048      ,     **snake_case   :    int      ,     ):
													'''simple docstring'''





													A__    :	Any			=	AddedToken(snake_case      ,     lstrip=snake_case      ,     rstrip=snake_case				) if isinstance(snake_case      ,     snake_case				) else pad_token
													A__    :	int			=	AddedToken(snake_case      ,     lstrip=snake_case      ,     rstrip=snake_case				) if isinstance(snake_case      ,     snake_case				) else bos_token
													A__    :	Any			=	AddedToken(snake_case      ,     lstrip=snake_case      ,     rstrip=snake_case				) if isinstance(snake_case      ,     snake_case				) else eos_token
													A__    :	Dict			=	AddedToken(snake_case      ,     lstrip=snake_case      ,     rstrip=snake_case				) if isinstance(snake_case      ,     snake_case				) else mask_token
													A__    :	str			=	AddedToken(snake_case      ,     lstrip=snake_case      ,     rstrip=snake_case				) if isinstance(snake_case      ,     snake_case				) else cls_token
													A__    :	Optional[Any]			=	AddedToken(snake_case      ,     lstrip=snake_case      ,     rstrip=snake_case				) if isinstance(snake_case      ,     snake_case				) else sep_token

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

													A__    :	List[Any]			=	2**8  # utf is 8 bits

													# define special tokens dict
													A__    :	Dict[str, int]			=	{
													    self.pad_token: 0,
													    self.bos_token: 1,
													    self.eos_token: 2,
													    self.mask_token: 3,
													    self.cls_token: 4,
													    self.sep_token: 5,
													}
													A__    :	Union[str, Any]			=	len(self.special_tokens_encoder				)
													A__    :	Dict[int, str]			=	{v: k for k, v in self.special_tokens_encoder.items()}


							def     _UpperCamelCase							(      self   :    Any				):
													'''simple docstring'''





													A__    :	str			=	self.special_tokens_encoder.copy()
													vocab.update(self.added_tokens_encoder				)
													for i in range(self._utf_vocab_size				):
																			A__    :	Tuple			=	chr(snake_case				)
																			A__    :	Any			=	i + len(self.special_tokens_encoder				)
													return vocab


							@property
							def     _UpperCamelCase							(      self   :    str				):
													'''simple docstring'''





													return self._utf_vocab_size + self._num_special_tokens


							def     _UpperCamelCase							(      self   :    Any      ,     snake_case   :    List[int]      ,     snake_case   :    Optional[List[int]] = None      ,     snake_case   :    bool = False				):
													'''simple docstring'''





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

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


							def     _UpperCamelCase							(      self   :    Dict      ,     snake_case   :    List[int]      ,     snake_case   :    Optional[List[int]] = None				):
													'''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     _UpperCamelCase							(      self   :    Union[str, Any]      ,     snake_case   :    str				):
													'''simple docstring'''





													A__    :	Tuple			=	[chr(snake_case				) for i in text.encode("""utf-8"""				)]
													return tokens


							def     _UpperCamelCase							(      self   :    Any      ,     snake_case   :    List[Any]				):
													'''simple docstring'''





													if token in self.special_tokens_encoder:
																			A__    :	List[Any]			=	self.special_tokens_encoder[token]
													elif token in self.added_tokens_encoder:
																			A__    :	List[str]			=	self.added_tokens_encoder[token]
													elif len(snake_case				) != 1:
																			A__    :	Any			=	self.unk_token_id
													else:
																			A__    :	List[Any]			=	ord(snake_case				) + self._num_special_tokens
													return token_id


							def     _UpperCamelCase							(      self   :    Tuple      ,     snake_case   :    Dict				):
													'''simple docstring'''





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


							def     _UpperCamelCase							(      self   :    Dict      ,     snake_case   :    List[str]				):
													'''simple docstring'''





													A__    :	Optional[int]			=	b""""""
													for token in tokens:
																			if token in self.special_tokens_decoder:
																									A__    :	List[Any]			=	self.special_tokens_decoder[token].encode("""utf-8"""				)
																			elif token in self.added_tokens_decoder:
																									A__    :	Union[str, Any]			=	self.special_tokens_decoder[token].encode("""utf-8"""				)
																			elif token in self.special_tokens_encoder:
																									A__    :	Optional[int]			=	token.encode("""utf-8"""				)
																			elif token in self.added_tokens_encoder:
																									A__    :	int			=	token.encode("""utf-8"""				)
																			else:
																									A__    :	Tuple			=	bytes([ord(snake_case				)]				)
																			bstring += tok_string
													A__    :	Tuple			=	bstring.decode("""utf-8"""      ,     errors="""replace"""				)
													return string


							def     _UpperCamelCase							(      self   :    Optional[int]      ,     snake_case   :    str      ,     snake_case   :    Optional[str] = None				):
													'''simple docstring'''





													return ()














"""simple docstring"""



from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


A_     =				{
    '''configuration_deformable_detr''': ['''DEFORMABLE_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DeformableDetrConfig'''],
}

try:
						if not is_vision_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						A_     =				['''DeformableDetrFeatureExtractor''']
						A_     =				['''DeformableDetrImageProcessor''']

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						A_     =				[
						    '''DEFORMABLE_DETR_PRETRAINED_MODEL_ARCHIVE_LIST''',
						    '''DeformableDetrForObjectDetection''',
						    '''DeformableDetrModel''',
						    '''DeformableDetrPreTrainedModel''',
						]


if TYPE_CHECKING:
						from .configuration_deformable_detr import DEFORMABLE_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP, DeformableDetrConfig

						try:
												if not is_vision_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .feature_extraction_deformable_detr import DeformableDetrFeatureExtractor
												from .image_processing_deformable_detr import DeformableDetrImageProcessor

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_deformable_detr import (
												    DEFORMABLE_DETR_PRETRAINED_MODEL_ARCHIVE_LIST,
												    DeformableDetrForObjectDetection,
												    DeformableDetrModel,
												    DeformableDetrPreTrainedModel,
												)

else:
						import sys

						A_     =				_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)






