






import copy

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


UpperCamelCase			    =     logging.get_logger(__name__)

UpperCamelCase			    =     {
    '''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		(_UpperCAmelCase   ):
			__snake_case    :				int									=							"deformable_detr"
			__snake_case    :				Any									=							{
			    "hidden_size": "d_model",
			    "num_attention_heads": "encoder_attention_heads",
			}







			def __init__(     self:  Dict				,     UpperCAmelCase_:  int=True				,     UpperCAmelCase_:  Union[str, Any]=None				,     UpperCAmelCase_:  Optional[int]=3				,     UpperCAmelCase_:  Any=300				,     UpperCAmelCase_:  str=1_024				,     UpperCAmelCase_:  Optional[int]=6				,     UpperCAmelCase_:  List[Any]=1_024				,     UpperCAmelCase_:  List[str]=8				,     UpperCAmelCase_:  Tuple=6				,     UpperCAmelCase_:  str=1_024				,     UpperCAmelCase_:  Tuple=8				,     UpperCAmelCase_:  str=0.0				,     UpperCAmelCase_:  str=True				,     UpperCAmelCase_:  Dict="relu"				,     UpperCAmelCase_:  int=256				,     UpperCAmelCase_:  Optional[Any]=0.1				,     UpperCAmelCase_:  Dict=0.0				,     UpperCAmelCase_:  List[Any]=0.0				,     UpperCAmelCase_:  Tuple=0.02				,     UpperCAmelCase_:  Any=1.0				,     UpperCAmelCase_:  List[Any]=True				,     UpperCAmelCase_:  Dict=False				,     UpperCAmelCase_:  List[Any]="sine"				,     UpperCAmelCase_:  Optional[Any]="resnet50"				,     UpperCAmelCase_:  str=True				,     UpperCAmelCase_:  List[str]=False				,     UpperCAmelCase_:  Tuple=4				,     UpperCAmelCase_:  Tuple=4				,     UpperCAmelCase_:  Optional[int]=4				,     UpperCAmelCase_:  int=False				,     UpperCAmelCase_:  Optional[int]=300				,     UpperCAmelCase_:  Tuple=False				,     UpperCAmelCase_:  Tuple=1				,     UpperCAmelCase_:  Dict=5				,     UpperCAmelCase_:  Any=2				,     UpperCAmelCase_:  List[str]=1				,     UpperCAmelCase_:  List[Any]=1				,     UpperCAmelCase_:  List[str]=5				,     UpperCAmelCase_:  int=2				,     UpperCAmelCase_:  Optional[int]=0.1				,     UpperCAmelCase_:  List[str]=0.25				,     UpperCAmelCase_:  str=False				,     **UpperCAmelCase_:  List[str]				,     ):







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







			@property
			def 							UpperCamelCase				(     self:  Union[str, Any]					):







									'''simple docstring'''




									return self.encoder_attention_heads







			@property
			def 							UpperCamelCase				(     self:  Tuple					):







									'''simple docstring'''




									return self.d_model







			def 							UpperCamelCase				(     self:  Tuple					):







									'''simple docstring'''




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









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


UpperCamelCase			    =     logging.get_logger(__name__)

UpperCamelCase			    =     {
    '''google/mobilenet_v1_1.0_224''': '''https://huggingface.co/google/mobilenet_v1_1.0_224/resolve/main/config.json''',
    '''google/mobilenet_v1_0.75_192''': '''https://huggingface.co/google/mobilenet_v1_0.75_192/resolve/main/config.json''',
    # See all MobileNetV1 models at https://huggingface.co/models?filter=mobilenet_v1
}



class 				__UpperCAmelCase		(_UpperCAmelCase   ):
			__snake_case    :				Any									=							"mobilenet_v1"







			def __init__(     self:  List[str]				,     UpperCAmelCase_:  List[Any]=3				,     UpperCAmelCase_:  List[str]=224				,     UpperCAmelCase_:  Optional[Any]=1.0				,     UpperCAmelCase_:  Dict=8				,     UpperCAmelCase_:  List[str]="relu6"				,     UpperCAmelCase_:  List[Any]=True				,     UpperCAmelCase_:  Dict=0.9_99				,     UpperCAmelCase_:  Union[str, Any]=0.02				,     UpperCAmelCase_:  Tuple=0.0_01				,     **UpperCAmelCase_:  List[str]				,     ):







									'''simple docstring'''




									super().__init__(**UpperCAmelCase_					)

									if depth_multiplier <= 0:
															raise ValueError("""depth_multiplier must be greater than zero."""					)

									_SCREAMING_SNAKE_CASE     				=  num_channels
									_SCREAMING_SNAKE_CASE     				=  image_size
									_SCREAMING_SNAKE_CASE     				=  depth_multiplier
									_SCREAMING_SNAKE_CASE     				=  min_depth
									_SCREAMING_SNAKE_CASE     				=  hidden_act
									_SCREAMING_SNAKE_CASE     				=  tf_padding
									_SCREAMING_SNAKE_CASE     				=  classifier_dropout_prob
									_SCREAMING_SNAKE_CASE     				=  initializer_range
									_SCREAMING_SNAKE_CASE     				=  layer_norm_eps



class 				__UpperCAmelCase		(_UpperCAmelCase   ):
			__snake_case    :				List[Any]									=							version.parse("1.11"   )







			@property
			def 							UpperCamelCase				(     self:  Tuple					):







									'''simple docstring'''




									return OrderedDict([("""pixel_values""", {0: """batch"""})]					)







			@property
			def 							UpperCamelCase				(     self:  Dict					):







									'''simple docstring'''




									if self.task == "image-classification":
															return OrderedDict([("""logits""", {0: """batch"""})]					)
									else:
															return OrderedDict([("""last_hidden_state""", {0: """batch"""}), ("""pooler_output""", {0: """batch"""})]					)







			@property
			def 							UpperCamelCase				(     self:  int					):







									'''simple docstring'''




									return 1E-4

