
"""simple docstring"""


from typing import List, Optional, Union

from ...image_utils import ImageInput
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType







class 				lowerCAmelCase_				(      _lowercase    ):



						'''simple docstring'''


						_lowerCamelCase:    int      =    ['''image_processor''', '''tokenizer''']
						_lowerCamelCase:    Optional[int]      =    '''BlipImageProcessor'''
						_lowerCamelCase:    Any      =    ('''BertTokenizer''', '''BertTokenizerFast''')


						def __init__( self     :      str  ,A_     :      str  ,A_     :      Any      )     ->   List[Any]:
							A						   =   False
							super().__init__(A_  ,A_      )
							A						   =   self.image_processor


						def __call__( self     :      Dict  ,A_     :      ImageInput = None  ,A_     :      Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None  ,A_     :      bool = True  ,A_     :      Union[bool, str, PaddingStrategy] = False  ,A_     :      Union[bool, str, TruncationStrategy] = None  ,A_     :      Optional[int] = None  ,A_     :      int = 0  ,A_     :      Optional[int] = None  ,A_     :      Optional[bool] = None  ,A_     :      bool = False  ,A_     :      bool = False  ,A_     :      bool = False  ,A_     :      bool = False  ,A_     :      bool = False  ,A_     :      bool = True  ,A_     :      Optional[Union[str, TensorType]] = None  ,**A_     :      Tuple  ,)     ->   BatchEncoding:
							if images is None and text is None:
								raise ValueError('You have to specify either images or text.'      )

							# Get only text
							if images is None:
								A						   =   self.tokenizer
								A						   =   self.tokenizer(
								    text=A_  ,add_special_tokens=A_  ,padding=A_  ,truncation=A_  ,max_length=A_  ,stride=A_  ,pad_to_multiple_of=A_  ,return_attention_mask=A_  ,return_overflowing_tokens=A_  ,return_special_tokens_mask=A_  ,return_offsets_mapping=A_  ,return_token_type_ids=A_  ,return_length=A_  ,verbose=A_  ,return_tensors=A_  ,**A_  ,)
								return text_encoding

							# add pixel_values
							A						   =   self.image_processor(A_  ,return_tensors=A_      )

							if text is not None:
								A						   =   self.tokenizer(
								    text=A_  ,add_special_tokens=A_  ,padding=A_  ,truncation=A_  ,max_length=A_  ,stride=A_  ,pad_to_multiple_of=A_  ,return_attention_mask=A_  ,return_overflowing_tokens=A_  ,return_special_tokens_mask=A_  ,return_offsets_mapping=A_  ,return_token_type_ids=A_  ,return_length=A_  ,verbose=A_  ,return_tensors=A_  ,**A_  ,)
							else:
								A						   =   None

							if text_encoding is not None:
								encoding_image_processor.update(A_      )

							return encoding_image_processor


						def 						_SCREAMING_SNAKE_CASE      ( self     :      int  ,*A_     :      Any  ,**A_     :      Optional[int]      )     ->   Union[str, Any]:
							return self.tokenizer.batch_decode(*A_  ,**A_      )


						def 						_SCREAMING_SNAKE_CASE      ( self     :      List[str]  ,*A_     :      str  ,**A_     :      Any      )     ->   Any:
							return self.tokenizer.decode(*A_  ,**A_      )




						@property
						def 						_SCREAMING_SNAKE_CASE      ( self     :      Union[str, Any]      )     ->   Optional[Any]:
							A						   =   self.tokenizer.model_input_names
							A						   =   self.image_processor.model_input_names
							return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names      )      )

"""simple docstring"""


from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


_lowercase							   =				logging.get_logger(__name__)

_lowercase							   =				{
    '''hustvl/yolos-small''': '''https://huggingface.co/hustvl/yolos-small/resolve/main/config.json''',
    # See all YOLOS models at https://huggingface.co/models?filter=yolos
}







class 				lowerCAmelCase_				(      _lowercase    ):



						'''simple docstring'''


						_lowerCamelCase:    List[str]      =    '''yolos'''


						def __init__( self     :      Dict  ,A_     :      Optional[Any]=768  ,A_     :      int=12  ,A_     :      List[str]=12  ,A_     :      str=3072  ,A_     :      Tuple="gelu"  ,A_     :      Dict=0.0  ,A_     :      List[Any]=0.0  ,A_     :      Any=0.02  ,A_     :      str=1e-12  ,A_     :      List[Any]=[512, 864]  ,A_     :      Union[str, Any]=16  ,A_     :      List[str]=3  ,A_     :      Optional[int]=True  ,A_     :      Tuple=100  ,A_     :      str=True  ,A_     :      Optional[Any]=False  ,A_     :      Any=1  ,A_     :      Optional[Any]=5  ,A_     :      Optional[Any]=2  ,A_     :      Optional[int]=5  ,A_     :      List[Any]=2  ,A_     :      Union[str, Any]=0.1  ,**A_     :      Tuple  ,)     ->   Any:
							super().__init__(**A_      )

							A						   =   hidden_size
							A						   =   num_hidden_layers
							A						   =   num_attention_heads
							A						   =   intermediate_size
							A						   =   hidden_act
							A						   =   hidden_dropout_prob
							A						   =   attention_probs_dropout_prob
							A						   =   initializer_range
							A						   =   layer_norm_eps
							A						   =   image_size
							A						   =   patch_size
							A						   =   num_channels
							A						   =   qkv_bias
							A						   =   num_detection_tokens
							A						   =   use_mid_position_embeddings
							A						   =   auxiliary_loss
							# Hungarian matcher
							A						   =   class_cost
							A						   =   bbox_cost
							A						   =   giou_cost
							# Loss coefficients
							A						   =   bbox_loss_coefficient
							A						   =   giou_loss_coefficient
							A						   =   eos_coefficient







class 				lowerCAmelCase_				(      _lowercase    ):



						'''simple docstring'''


						_lowerCamelCase:    Any      =    version.parse('''1.11'''    )


						@property
						def 						_SCREAMING_SNAKE_CASE      ( self     :      Optional[int]      )     ->   Mapping[str, Mapping[int, str]]:
							return OrderedDict(
							    [
							        ('pixel_values', {0: 'batch', 1: 'num_channels', 2: 'height', 3: 'width'}),
							    ]      )


						@property
						def 						_SCREAMING_SNAKE_CASE      ( self     :      Any      )     ->   float:
							return 1e-4




						@property
						def 						_SCREAMING_SNAKE_CASE      ( self     :      Tuple      )     ->   int:
							return 12