


"""simple docstring"""






import copy

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


UpperCAmelCase    :     int   						=		logging.get_logger(__name__)

UpperCAmelCase    :     Any   						=		{
    'ut/deta': 'https://huggingface.co/ut/deta/resolve/main/config.json',
}





class      lowerCamelCase__   (     A				):







					"""simple docstring"""


					__a	       =							"""deta"""
					__a	       =							{
					    """hidden_size""": """d_model""",
					    """num_attention_heads""": """encoder_attention_heads""",
					}






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






												if backbone_config is None:
																			logger.info("""`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone."""  )
																			__UpperCAmelCase   :						Optional[int]      							=					CONFIG_MAPPING["""resnet"""](out_features=["""stage2""", """stage3""", """stage4"""]  )
												else:
																			if isinstance(UpperCamelCase ,       UpperCamelCase  ):
																										__UpperCAmelCase   :						Optional[int]      							=					backbone_config.pop("""model_type"""  )
																										__UpperCAmelCase   :						Any      							=					CONFIG_MAPPING[backbone_model_type]
																										__UpperCAmelCase   :						Optional[Any]      							=					config_class.from_dict(UpperCamelCase  )

												__UpperCAmelCase   :						str      							=					backbone_config
												__UpperCAmelCase   :						List[Any]      							=					num_queries
												__UpperCAmelCase   :						Tuple      							=					max_position_embeddings
												__UpperCAmelCase   :						str      							=					d_model
												__UpperCAmelCase   :						Optional[int]      							=					encoder_ffn_dim
												__UpperCAmelCase   :						Union[str, Any]      							=					encoder_layers
												__UpperCAmelCase   :						Optional[int]      							=					encoder_attention_heads
												__UpperCAmelCase   :						Optional[int]      							=					decoder_ffn_dim
												__UpperCAmelCase   :						Tuple      							=					decoder_layers
												__UpperCAmelCase   :						Optional[int]      							=					decoder_attention_heads
												__UpperCAmelCase   :						Union[str, Any]      							=					dropout
												__UpperCAmelCase   :						List[str]      							=					attention_dropout
												__UpperCAmelCase   :						List[str]      							=					activation_dropout
												__UpperCAmelCase   :						Dict      							=					activation_function
												__UpperCAmelCase   :						List[str]      							=					init_std
												__UpperCAmelCase   :						str      							=					init_xavier_std
												__UpperCAmelCase   :						Tuple      							=					encoder_layerdrop
												__UpperCAmelCase   :						Union[str, Any]      							=					auxiliary_loss
												__UpperCAmelCase   :						int      							=					position_embedding_type
												# deformable attributes
												__UpperCAmelCase   :						List[str]      							=					num_feature_levels
												__UpperCAmelCase   :						Tuple      							=					encoder_n_points
												__UpperCAmelCase   :						Union[str, Any]      							=					decoder_n_points
												__UpperCAmelCase   :						Dict      							=					two_stage
												__UpperCAmelCase   :						List[str]      							=					two_stage_num_proposals
												__UpperCAmelCase   :						Any      							=					with_box_refine
												__UpperCAmelCase   :						Any      							=					assign_first_stage
												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
												__UpperCAmelCase   :						Any      							=					class_cost
												__UpperCAmelCase   :						Union[str, Any]      							=					bbox_cost
												__UpperCAmelCase   :						List[str]      							=					giou_cost
												# Loss coefficients
												__UpperCAmelCase   :						Dict      							=					mask_loss_coefficient
												__UpperCAmelCase   :						Optional[Any]      							=					dice_loss_coefficient
												__UpperCAmelCase   :						Tuple      							=					bbox_loss_coefficient
												__UpperCAmelCase   :						Optional[Any]      							=					giou_loss_coefficient
												__UpperCAmelCase   :						Any      							=					eos_coefficient
												__UpperCAmelCase   :						Optional[int]      							=					focal_alpha
												super().__init__(is_encoder_decoder=UpperCamelCase ,       **UpperCamelCase  )






					@property
					def lowerCamelCase__							(       self    : Any  ):
												'''simple docstring'''






												return self.encoder_attention_heads






					@property
					def lowerCamelCase__							(       self    : Dict  ):
												'''simple docstring'''






												return self.d_model






					def lowerCamelCase__							(       self    : str  ):
												'''simple docstring'''






												__UpperCAmelCase   :						Tuple      							=					copy.deepcopy(self.__dict__  )
												__UpperCAmelCase   :						Optional[Any]      							=					self.backbone_config.to_dict()
												__UpperCAmelCase   :						str      							=					self.__class__.model_type
												return output




"""simple docstring"""






import os
import sys
from contextlib import contextmanager


# Windows only
if os.name == "nt":
							import ctypes
							import msvcrt  # noqa





							class      lowerCamelCase__   (     ctypes.Structure				):







												"""simple docstring"""


												__a	       =							[("""size""", ctypes.c_int), ("""visible""", ctypes.c_byte)]
def      lowerCamelCase       (     )		->       Optional[int]:

							'''simple docstring'''



							if os.name == "nt":
														__UpperCAmelCase   :						Dict      							=					CursorInfo()
														__UpperCAmelCase   :						Any      							=					ctypes.windll.kernelaa.GetStdHandle(-1_1							)
														ctypes.windll.kernelaa.GetConsoleCursorInfo(_UpperCamelCase       ,			ctypes.byref(_UpperCamelCase							)							)
														__UpperCAmelCase   :						Tuple      							=					False
														ctypes.windll.kernelaa.SetConsoleCursorInfo(_UpperCamelCase       ,			ctypes.byref(_UpperCamelCase							)							)
							elif os.name == "posix":
														sys.stdout.write("""\033[?25l"""							)
														sys.stdout.flush()
def      lowerCamelCase       (     )		->       Optional[int]:

							'''simple docstring'''



							if os.name == "nt":
														__UpperCAmelCase   :						str      							=					CursorInfo()
														__UpperCAmelCase   :						int      							=					ctypes.windll.kernelaa.GetStdHandle(-1_1							)
														ctypes.windll.kernelaa.GetConsoleCursorInfo(_UpperCamelCase       ,			ctypes.byref(_UpperCamelCase							)							)
														__UpperCAmelCase   :						Union[str, Any]      							=					True
														ctypes.windll.kernelaa.SetConsoleCursorInfo(_UpperCamelCase       ,			ctypes.byref(_UpperCamelCase							)							)
							elif os.name == "posix":
														sys.stdout.write("""\033[?25h"""							)
														sys.stdout.flush()
@contextmanager
def      lowerCamelCase       (     )		->       str:

							'''simple docstring'''



							try:
														hide_cursor()
														yield
							finally:
														show_cursor()
