




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
from ..auto import CONFIG_MAPPING


UpperCamelCase__ :   Tuple						=							logging.get_logger(__name__)

UpperCamelCase__ :   int						=							{
    '''microsoft/table-transformer-detection''': (
        '''https://huggingface.co/microsoft/table-transformer-detection/resolve/main/config.json'''
    ),
}







class 				lowerCAmelCase_       (					a__							):
				__a     :       Tuple						=     """table-transformer"""
				__a     :       Optional[int]						=     ["""past_key_values"""]
				__a     :       Dict						=     {
				    """hidden_size""": """d_model""",
				    """num_attention_heads""": """encoder_attention_heads""",
				}






				def __init__(			self      ,snake_case__=True      ,snake_case__=None      ,snake_case__=3      ,snake_case__=100      ,snake_case__=6      ,snake_case__=2048      ,snake_case__=8      ,snake_case__=6      ,snake_case__=2048      ,snake_case__=8      ,snake_case__=0.0      ,snake_case__=0.0      ,snake_case__=True      ,snake_case__="relu"      ,snake_case__=256      ,snake_case__=0.1      ,snake_case__=0.0      ,snake_case__=0.0      ,snake_case__=0.02      ,snake_case__=1.0      ,snake_case__=False      ,snake_case__="sine"      ,snake_case__="resnet50"      ,snake_case__=True      ,snake_case__=False      ,snake_case__=1      ,snake_case__=5      ,snake_case__=2      ,snake_case__=1      ,snake_case__=1      ,snake_case__=5      ,snake_case__=2      ,snake_case__=0.1      ,**snake_case__      ,):
							if backbone_config is not None and use_timm_backbone:
										raise ValueError('You can\'t specify both `backbone_config` and `use_timm_backbone`.' )

							if not use_timm_backbone:
										if backbone_config is None:
													logger.info('`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone.' )
													SCREAMING_SNAKE_CASE_   : Tuple					  =      CONFIG_MAPPING["resnet"](out_features=['stage4'] )
										elif isinstance(lowerCAmelCase__      ,lowerCAmelCase__ ):
													SCREAMING_SNAKE_CASE_   : Any					  =      backbone_config.get('model_type' )
													SCREAMING_SNAKE_CASE_   : int					  =      CONFIG_MAPPING[backbone_model_type]
													SCREAMING_SNAKE_CASE_   : List[str]					  =      config_class.from_dict(lowerCAmelCase__ )
										# set timm attributes to None
										SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      None, None, None

							SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      use_timm_backbone
							SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      backbone_config
							SCREAMING_SNAKE_CASE_   : Tuple					  =      num_channels
							SCREAMING_SNAKE_CASE_   : str					  =      num_queries
							SCREAMING_SNAKE_CASE_   : List[str]					  =      d_model
							SCREAMING_SNAKE_CASE_   : List[Any]					  =      encoder_ffn_dim
							SCREAMING_SNAKE_CASE_   : List[str]					  =      encoder_layers
							SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      encoder_attention_heads
							SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      decoder_ffn_dim
							SCREAMING_SNAKE_CASE_   : Any					  =      decoder_layers
							SCREAMING_SNAKE_CASE_   : List[Any]					  =      decoder_attention_heads
							SCREAMING_SNAKE_CASE_   : Dict					  =      dropout
							SCREAMING_SNAKE_CASE_   : List[str]					  =      attention_dropout
							SCREAMING_SNAKE_CASE_   : List[str]					  =      activation_dropout
							SCREAMING_SNAKE_CASE_   : Any					  =      activation_function
							SCREAMING_SNAKE_CASE_   : List[str]					  =      init_std
							SCREAMING_SNAKE_CASE_   : Dict					  =      init_xavier_std
							SCREAMING_SNAKE_CASE_   : List[Any]					  =      encoder_layerdrop
							SCREAMING_SNAKE_CASE_   : int					  =      decoder_layerdrop
							SCREAMING_SNAKE_CASE_   : int					  =      encoder_layers
							SCREAMING_SNAKE_CASE_   : int					  =      auxiliary_loss
							SCREAMING_SNAKE_CASE_   : Tuple					  =      position_embedding_type
							SCREAMING_SNAKE_CASE_   : Optional[int]					  =      backbone
							SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      use_pretrained_backbone
							SCREAMING_SNAKE_CASE_   : List[Any]					  =      dilation
							# Hungarian matcher
							SCREAMING_SNAKE_CASE_   : Any					  =      class_cost
							SCREAMING_SNAKE_CASE_   : Optional[int]					  =      bbox_cost
							SCREAMING_SNAKE_CASE_   : Any					  =      giou_cost
							# Loss coefficients
							SCREAMING_SNAKE_CASE_   : int					  =      mask_loss_coefficient
							SCREAMING_SNAKE_CASE_   : int					  =      dice_loss_coefficient
							SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      bbox_loss_coefficient
							SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      giou_loss_coefficient
							SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      eos_coefficient
							super().__init__(is_encoder_decoder=lowerCAmelCase__      ,**lowerCAmelCase__ )






				@property
				def 		snake_case	(			self ):
							return self.encoder_attention_heads






				@property
				def 		snake_case	(			self ):
							return self.d_model







class 				lowerCAmelCase_       (					a__							):
				__a     :       Optional[int]						=     version.parse("1.11"							)






				@property
				def 		snake_case	(			self ):
							return OrderedDict(
							    [
							        ('pixel_values', {0: 'batch', 1: 'num_channels', 2: 'height', 3: 'width'}),
							        ('pixel_mask', {0: 'batch'}),
							    ] )






				@property
				def 		snake_case	(			self ):
							return 1E-5






				@property
				def 		snake_case	(			self ):
							return 12










"""simple docstring"""




from typing import TYPE_CHECKING

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


a		:					Optional[Any]	      =     {
    '''configuration_owlvit''': [
        '''OWLVIT_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''OwlViTConfig''',
        '''OwlViTOnnxConfig''',
        '''OwlViTTextConfig''',
        '''OwlViTVisionConfig''',
    ],
    '''processing_owlvit''': ['''OwlViTProcessor'''],
}


try:
		if not is_vision_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		a		:					str	      =     ['''OwlViTFeatureExtractor''']
		a		:					List[Any]	      =     ['''OwlViTImageProcessor''']

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		a		:					List[Any]	      =     [
		    '''OWLVIT_PRETRAINED_MODEL_ARCHIVE_LIST''',
		    '''OwlViTModel''',
		    '''OwlViTPreTrainedModel''',
		    '''OwlViTTextModel''',
		    '''OwlViTVisionModel''',
		    '''OwlViTForObjectDetection''',
		]

if TYPE_CHECKING:
		from .configuration_owlvit import (
		    OWLVIT_PRETRAINED_CONFIG_ARCHIVE_MAP,
		    OwlViTConfig,
		    OwlViTOnnxConfig,
		    OwlViTTextConfig,
		    OwlViTVisionConfig,
		)
		from .processing_owlvit import OwlViTProcessor

		try:
				if not is_vision_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .feature_extraction_owlvit import OwlViTFeatureExtractor
				from .image_processing_owlvit import OwlViTImageProcessor

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_owlvit import (
				    OWLVIT_PRETRAINED_MODEL_ARCHIVE_LIST,
				    OwlViTForObjectDetection,
				    OwlViTModel,
				    OwlViTPreTrainedModel,
				    OwlViTTextModel,
				    OwlViTVisionModel,
				)

else:
		import sys

		a		:					List[str]	      =     _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)


