


import copy

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


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

a_ :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 							lowercase  (						_UpperCAmelCase			):
     lowerCamelCase			:			Tuple      = '''deformable_detr'''
     lowerCamelCase			:			Optional[int]      = {
         '''hidden_size''': '''d_model''',
         '''num_attention_heads''': '''encoder_attention_heads''',
     }







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







     @property
     def 							lowercase__       (						self :						Optional[int]      ):
           return self.encoder_attention_heads







     @property
     def 							lowercase__       (						self :						Optional[int]      ):
           return self.d_model







     def 							lowercase__       (						self :						int      ):
           SCREAMING_SNAKE_CASE__       :  List[str]						     =		copy.deepcopy(self.__dict__      )
           if self.backbone_config is not None:
                 SCREAMING_SNAKE_CASE__       :  List[str]						     =		self.backbone_config.to_dict()
           SCREAMING_SNAKE_CASE__       :  str						     =		self.__class__.model_type
           return output







'''simple docstring'''






_UpperCAmelCase    :     Any         =       '''0.21.0'''

from .accelerator import Accelerator
from .big_modeling import (
    cpu_offload,
    cpu_offload_with_hook,
    disk_offload,
    dispatch_model,
    init_empty_weights,
    init_on_device,
    load_checkpoint_and_dispatch,
)
from .data_loader import skip_first_batches
from .launchers import debug_launcher, notebook_launcher
from .state import PartialState
from .utils import (
    DeepSpeedPlugin,
    DistributedDataParallelKwargs,
    DistributedType,
    FullyShardedDataParallelPlugin,
    GradScalerKwargs,
    InitProcessGroupKwargs,
    find_executable_batch_size,
    infer_auto_device_map,
    is_rich_available,
    load_checkpoint_in_model,
    synchronize_rng_states,
)


if is_rich_available():
   from .utils import rich



