




'''simple docstring'''


import copy

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


_snake_case   :   Union[str, Any]     							=	logging.get_logger(__name__)

_snake_case   :   int     							=	{
    '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     A					(	SCREAMING_SNAKE_CASE_					):
							lowercase_           =       'deformable_detr'
							lowercase_           =       {
							    'hidden_size': 'd_model',
							    'num_attention_heads': 'encoder_attention_heads',
							}







							def __init__(						self :						Tuple							,    lowerCAmelCase_ :						Dict=True							,    lowerCAmelCase_ :						int=None							,    lowerCAmelCase_ :						Dict=3							,    lowerCAmelCase_ :						Optional[int]=3_00							,    lowerCAmelCase_ :						Tuple=10_24							,    lowerCAmelCase_ :						Optional[int]=6							,    lowerCAmelCase_ :						Any=10_24							,    lowerCAmelCase_ :						Tuple=8							,    lowerCAmelCase_ :						Optional[int]=6							,    lowerCAmelCase_ :						Optional[int]=10_24							,    lowerCAmelCase_ :						Union[str, Any]=8							,    lowerCAmelCase_ :						List[str]=0.0							,    lowerCAmelCase_ :						int=True							,    lowerCAmelCase_ :						Any="relu"							,    lowerCAmelCase_ :						int=2_56							,    lowerCAmelCase_ :						List[str]=0.1							,    lowerCAmelCase_ :						str=0.0							,    lowerCAmelCase_ :						Tuple=0.0							,    lowerCAmelCase_ :						Union[str, Any]=0.0_2							,    lowerCAmelCase_ :						Any=1.0							,    lowerCAmelCase_ :						str=True							,    lowerCAmelCase_ :						Tuple=False							,    lowerCAmelCase_ :						Dict="sine"							,    lowerCAmelCase_ :						Any="resnet50"							,    lowerCAmelCase_ :						Optional[int]=True							,    lowerCAmelCase_ :						Dict=False							,    lowerCAmelCase_ :						Optional[Any]=4							,    lowerCAmelCase_ :						Union[str, Any]=4							,    lowerCAmelCase_ :						Dict=4							,    lowerCAmelCase_ :						Tuple=False							,    lowerCAmelCase_ :						Optional[Any]=3_00							,    lowerCAmelCase_ :						Tuple=False							,    lowerCAmelCase_ :						Union[str, Any]=1							,    lowerCAmelCase_ :						List[Any]=5							,    lowerCAmelCase_ :						List[str]=2							,    lowerCAmelCase_ :						Optional[int]=1							,    lowerCAmelCase_ :						Optional[Any]=1							,    lowerCAmelCase_ :						List[Any]=5							,    lowerCAmelCase_ :						Union[str, Any]=2							,    lowerCAmelCase_ :						Union[str, Any]=0.1							,    lowerCAmelCase_ :						Dict=0.2_5							,    lowerCAmelCase_ :						List[str]=False							,    **lowerCAmelCase_ :						int							,    )    ->							Any:


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







							@property
							def      __lowerCAmelCase    (						self :						Optional[Any]      )    ->							Union[str, Any]:


														"""simple docstring"""


														return self.encoder_attention_heads







							@property
							def      __lowerCAmelCase    (						self :						List[Any]      )    ->							Union[str, Any]:


														"""simple docstring"""


														return self.d_model







							def      __lowerCAmelCase    (						self :						Dict      )    ->							Tuple:


														"""simple docstring"""


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







'''simple docstring'''


_snake_case   :   Any     							=	tuple[float, float, float]
_snake_case   :   Optional[int]     							=	tuple[float, float, float]
def 	snake_case_					(UpperCamelCase :						Pointad				,		UpperCamelCase :						Pointad   ):





							'''simple docstring'''


							_a			  =       end_pointa[0] - end_pointa[0]
							_a			  =       end_pointa[1] - end_pointa[1]
							_a			  =       end_pointa[2] - end_pointa[2]
							return (x, y, z)
def 	snake_case_					(UpperCamelCase :						Vectorad				,		UpperCamelCase :						Vectorad   ):





							'''simple docstring'''


							_a			  =       ab[1] * ac[2] - ab[2] * ac[1]  # *i
							_a			  =       (ab[0] * ac[2] - ab[2] * ac[0]) * -1  # *j
							_a			  =       ab[0] * ac[1] - ab[1] * ac[0]  # *k
							return (x, y, z)
def 	snake_case_					(UpperCamelCase :						Vectorad				,		UpperCamelCase :						int   ):





							'''simple docstring'''


							return tuple(round(UpperCamelCase				,		UpperCamelCase   ) for x in vector   ) == (0, 0, 0)

def 	snake_case_					(UpperCamelCase :						Pointad				,		UpperCamelCase :						Pointad				,		UpperCamelCase :						Pointad				,		UpperCamelCase :						int = 10   ):





							'''simple docstring'''


							_a			  =       create_vector(UpperCamelCase				,		UpperCamelCase   )
							_a			  =       create_vector(UpperCamelCase				,		UpperCamelCase   )
							return is_zero_vector(get_ad_vectors_cross(UpperCamelCase				,		UpperCamelCase   )				,		UpperCamelCase   )

