
'''simple docstring'''



import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto import CONFIG_MAPPING


_lowercase    =		logging.get_logger(__name__)

_lowercase    =		{
    """SenseTime/deformable-detr""": """https://huggingface.co/sensetime/deformable-detr/resolve/main/config.json""",
    # See all Deformable DETR models at https://huggingface.co/models?filter=deformable-detr
}




class   UpperCAmelCase_					(		_SCREAMING_SNAKE_CASE			):






						'''simple docstring'''






						_lowercase		:				List[Any]									=       '''deformable_detr'''
						_lowercase		:				List[Any]									=       {
						    '''hidden_size''': '''d_model''',
						    '''num_attention_heads''': '''encoder_attention_heads''',
						}




						def __init__( self   ,       _lowercase=True   ,       _lowercase=None   ,       _lowercase=3   ,       _lowercase=300   ,       _lowercase=1_024   ,       _lowercase=6   ,       _lowercase=1_024   ,       _lowercase=8   ,       _lowercase=6   ,       _lowercase=1_024   ,       _lowercase=8   ,       _lowercase=0.0   ,       _lowercase=True   ,       _lowercase="relu"   ,       _lowercase=256   ,       _lowercase=0.1   ,       _lowercase=0.0   ,       _lowercase=0.0   ,       _lowercase=0.02   ,       _lowercase=1.0   ,       _lowercase=True   ,       _lowercase=False   ,       _lowercase="sine"   ,       _lowercase="resnet50"   ,       _lowercase=True   ,       _lowercase=False   ,       _lowercase=4   ,       _lowercase=4   ,       _lowercase=4   ,       _lowercase=False   ,       _lowercase=300   ,       _lowercase=False   ,       _lowercase=1   ,       _lowercase=5   ,       _lowercase=2   ,       _lowercase=1   ,       _lowercase=1   ,       _lowercase=5   ,       _lowercase=2   ,       _lowercase=0.1   ,       _lowercase=0.25   ,       _lowercase=False   ,       **_lowercase   ,       ):

												"""simple docstring"""



												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."""				)
																								_lowerCAmelCase  						=			CONFIG_MAPPING["""resnet"""](out_features=["""stage4"""]				)
																		elif isinstance(_lowercase   ,       _lowercase				):
																								_lowerCAmelCase  						=			backbone_config.get("""model_type"""				)
																								_lowerCAmelCase  						=			CONFIG_MAPPING[backbone_model_type]
																								_lowerCAmelCase  						=			config_class.from_dict(_lowercase				)
												_lowerCAmelCase  						=			use_timm_backbone
												_lowerCAmelCase  						=			backbone_config
												_lowerCAmelCase  						=			num_channels
												_lowerCAmelCase  						=			num_queries
												_lowerCAmelCase  						=			max_position_embeddings
												_lowerCAmelCase  						=			d_model
												_lowerCAmelCase  						=			encoder_ffn_dim
												_lowerCAmelCase  						=			encoder_layers
												_lowerCAmelCase  						=			encoder_attention_heads
												_lowerCAmelCase  						=			decoder_ffn_dim
												_lowerCAmelCase  						=			decoder_layers
												_lowerCAmelCase  						=			decoder_attention_heads
												_lowerCAmelCase  						=			dropout
												_lowerCAmelCase  						=			attention_dropout
												_lowerCAmelCase  						=			activation_dropout
												_lowerCAmelCase  						=			activation_function
												_lowerCAmelCase  						=			init_std
												_lowerCAmelCase  						=			init_xavier_std
												_lowerCAmelCase  						=			encoder_layerdrop
												_lowerCAmelCase  						=			auxiliary_loss
												_lowerCAmelCase  						=			position_embedding_type
												_lowerCAmelCase  						=			backbone
												_lowerCAmelCase  						=			use_pretrained_backbone
												_lowerCAmelCase  						=			dilation
												# deformable attributes
												_lowerCAmelCase  						=			num_feature_levels
												_lowerCAmelCase  						=			encoder_n_points
												_lowerCAmelCase  						=			decoder_n_points
												_lowerCAmelCase  						=			two_stage
												_lowerCAmelCase  						=			two_stage_num_proposals
												_lowerCAmelCase  						=			with_box_refine
												if two_stage is True and with_box_refine is False:
																		raise ValueError("""If two_stage is True, with_box_refine must be True."""				)
												# Hungarian matcher
												_lowerCAmelCase  						=			class_cost
												_lowerCAmelCase  						=			bbox_cost
												_lowerCAmelCase  						=			giou_cost
												# Loss coefficients
												_lowerCAmelCase  						=			mask_loss_coefficient
												_lowerCAmelCase  						=			dice_loss_coefficient
												_lowerCAmelCase  						=			bbox_loss_coefficient
												_lowerCAmelCase  						=			giou_loss_coefficient
												_lowerCAmelCase  						=			eos_coefficient
												_lowerCAmelCase  						=			focal_alpha
												_lowerCAmelCase  						=			disable_custom_kernels
												super().__init__(is_encoder_decoder=_lowercase   ,       **_lowercase				)




						@property
						def  _lowercase     ( self				):

												"""simple docstring"""



												return self.encoder_attention_heads




						@property
						def  _lowercase     ( self				):

												"""simple docstring"""



												return self.d_model




						def  _lowercase     ( self				):

												"""simple docstring"""



												_lowerCAmelCase  						=			copy.deepcopy(self.__dict__				)
												if self.backbone_config is not None:
																		_lowerCAmelCase  						=			self.backbone_config.to_dict()
												_lowerCAmelCase  						=			self.__class__.model_type
												return output


'''simple docstring'''



from typing import TYPE_CHECKING

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


_lowercase    =		{"""configuration_deit""": ["""DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """DeiTConfig""", """DeiTOnnxConfig"""]}

try:
						if not is_vision_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						_lowercase    =		["""DeiTFeatureExtractor"""]
						_lowercase    =		["""DeiTImageProcessor"""]

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						_lowercase    =		[
						    """DEIT_PRETRAINED_MODEL_ARCHIVE_LIST""",
						    """DeiTForImageClassification""",
						    """DeiTForImageClassificationWithTeacher""",
						    """DeiTForMaskedImageModeling""",
						    """DeiTModel""",
						    """DeiTPreTrainedModel""",
						]

try:
						if not is_tf_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						_lowercase    =		[
						    """TF_DEIT_PRETRAINED_MODEL_ARCHIVE_LIST""",
						    """TFDeiTForImageClassification""",
						    """TFDeiTForImageClassificationWithTeacher""",
						    """TFDeiTForMaskedImageModeling""",
						    """TFDeiTModel""",
						    """TFDeiTPreTrainedModel""",
						]


if TYPE_CHECKING:
						from .configuration_deit import DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP, DeiTConfig, DeiTOnnxConfig

						try:
												if not is_vision_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .feature_extraction_deit import DeiTFeatureExtractor
												from .image_processing_deit import DeiTImageProcessor

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_deit import (
												    DEIT_PRETRAINED_MODEL_ARCHIVE_LIST,
												    DeiTForImageClassification,
												    DeiTForImageClassificationWithTeacher,
												    DeiTForMaskedImageModeling,
												    DeiTModel,
												    DeiTPreTrainedModel,
												)

						try:
												if not is_tf_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_tf_deit import (
												    TF_DEIT_PRETRAINED_MODEL_ARCHIVE_LIST,
												    TFDeiTForImageClassification,
												    TFDeiTForImageClassificationWithTeacher,
												    TFDeiTForMaskedImageModeling,
												    TFDeiTModel,
												    TFDeiTPreTrainedModel,
												)


else:
						import sys

						_lowercase    =		_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)
