


from typing import TYPE_CHECKING

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


_lowerCAmelCase  :		Dict		     =	{'configuration_vit_mae': ['VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ViTMAEConfig']}

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_lowerCAmelCase  :		str		     =	[
				    'VIT_MAE_PRETRAINED_MODEL_ARCHIVE_LIST',
				    'ViTMAEForPreTraining',
				    'ViTMAELayer',
				    'ViTMAEModel',
				    'ViTMAEPreTrainedModel',
				]

try:
				if not is_tf_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_lowerCAmelCase  :		str		     =	[
				    'TFViTMAEForPreTraining',
				    'TFViTMAEModel',
				    'TFViTMAEPreTrainedModel',
				]

if TYPE_CHECKING:
				from .configuration_vit_mae import VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP, ViTMAEConfig

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_vit_mae import (
								    VIT_MAE_PRETRAINED_MODEL_ARCHIVE_LIST,
								    ViTMAEForPreTraining,
								    ViTMAELayer,
								    ViTMAEModel,
								    ViTMAEPreTrainedModel,
								)

				try:
								if not is_tf_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_tf_vit_mae import TFViTMAEForPreTraining, TFViTMAEModel, TFViTMAEPreTrainedModel


else:
				import sys

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




'''simple docstring'''




import copy

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


_lowerCAmelCase  :		Optional[Any]		     =	logging.get_logger(__name__)

_lowerCAmelCase  :		Dict		     =	{
    '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  lowerCAmelCase				(				a							):
	_lowerCamelCase   :					Any			      = """deformable_detr"""
	_lowerCamelCase   :					List[str]			      = {
	    """hidden_size""": """d_model""",
	    """num_attention_heads""": """encoder_attention_heads""",
	}



	def __init__(					self ,					snake_case__=True ,					snake_case__=None ,					snake_case__=3 ,					snake_case__=300 ,					snake_case__=1024 ,					snake_case__=6 ,					snake_case__=1024 ,					snake_case__=8 ,					snake_case__=6 ,					snake_case__=1024 ,					snake_case__=8 ,					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.0_2 ,					snake_case__=1.0 ,					snake_case__=True ,					snake_case__=False ,					snake_case__="sine" ,					snake_case__="resnet50" ,					snake_case__=True ,					snake_case__=False ,					snake_case__=4 ,					snake_case__=4 ,					snake_case__=4 ,					snake_case__=False ,					snake_case__=300 ,					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__=0.2_5 ,					snake_case__=False ,					**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.'    )
				lowerCAmelCase					:    Optional[int]      							= CONFIG_MAPPING['resnet'](out_features=['stage4']    )
			elif isinstance(snake_case__ ,					snake_case__    ):
				lowerCAmelCase					:    List[str]      							= backbone_config.get('model_type'    )
				lowerCAmelCase					:    str      							= CONFIG_MAPPING[backbone_model_type]
				lowerCAmelCase					:    Optional[Any]      							= config_class.from_dict(snake_case__    )
		lowerCAmelCase					:    Union[str, Any]      							= use_timm_backbone
		lowerCAmelCase					:    List[Any]      							= backbone_config
		lowerCAmelCase					:    Any      							= num_channels
		lowerCAmelCase					:    Tuple      							= num_queries
		lowerCAmelCase					:    Dict      							= max_position_embeddings
		lowerCAmelCase					:    int      							= d_model
		lowerCAmelCase					:    List[str]      							= encoder_ffn_dim
		lowerCAmelCase					:    List[str]      							= encoder_layers
		lowerCAmelCase					:    int      							= encoder_attention_heads
		lowerCAmelCase					:    str      							= decoder_ffn_dim
		lowerCAmelCase					:    str      							= decoder_layers
		lowerCAmelCase					:    Dict      							= decoder_attention_heads
		lowerCAmelCase					:    str      							= dropout
		lowerCAmelCase					:    List[str]      							= attention_dropout
		lowerCAmelCase					:    Union[str, Any]      							= activation_dropout
		lowerCAmelCase					:    str      							= activation_function
		lowerCAmelCase					:    Any      							= init_std
		lowerCAmelCase					:    Any      							= init_xavier_std
		lowerCAmelCase					:    Dict      							= encoder_layerdrop
		lowerCAmelCase					:    int      							= auxiliary_loss
		lowerCAmelCase					:    Optional[Any]      							= position_embedding_type
		lowerCAmelCase					:    List[str]      							= backbone
		lowerCAmelCase					:    int      							= use_pretrained_backbone
		lowerCAmelCase					:    int      							= dilation
		# deformable attributes
		lowerCAmelCase					:    List[str]      							= num_feature_levels
		lowerCAmelCase					:    List[str]      							= encoder_n_points
		lowerCAmelCase					:    Union[str, Any]      							= decoder_n_points
		lowerCAmelCase					:    Tuple      							= two_stage
		lowerCAmelCase					:    Dict      							= two_stage_num_proposals
		lowerCAmelCase					:    Union[str, Any]      							= 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					:    Union[str, Any]      							= class_cost
		lowerCAmelCase					:    Dict      							= bbox_cost
		lowerCAmelCase					:    List[Any]      							= giou_cost
		# Loss coefficients
		lowerCAmelCase					:    Dict      							= mask_loss_coefficient
		lowerCAmelCase					:    Any      							= dice_loss_coefficient
		lowerCAmelCase					:    str      							= bbox_loss_coefficient
		lowerCAmelCase					:    Tuple      							= giou_loss_coefficient
		lowerCAmelCase					:    List[str]      							= eos_coefficient
		lowerCAmelCase					:    Any      							= focal_alpha
		lowerCAmelCase					:    Dict      							= disable_custom_kernels
		super().__init__(is_encoder_decoder=snake_case__ ,					**snake_case__    )



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



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



	def 				lowercase     (					self    ):
		lowerCAmelCase					:    Union[str, Any]      							= copy.deepcopy(self.__dict__    )
		if self.backbone_config is not None:
			lowerCAmelCase					:    List[Any]      							= self.backbone_config.to_dict()
		lowerCAmelCase					:    str      							= self.__class__.model_type
		return output
