


import copy

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


__a     =			logging.get_logger(__name__)

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





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





      @property
      def        _lowercase				(		self						:					Any       )    ->   int:






         """simple docstring"""







         return self.encoder_attention_heads





      @property
      def        _lowercase				(		self						:					str       )    ->   int:






         """simple docstring"""







         return self.d_model





      def        _lowercase				(		self						:					int       )    ->   Union[str, Any]:






         """simple docstring"""







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







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available


__a     =			{"""tokenization_herbert""": ["""HerbertTokenizer"""]}

try:
 if not is_tokenizers_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __a     =			["""HerbertTokenizerFast"""]


if TYPE_CHECKING:
 from .tokenization_herbert import HerbertTokenizer

 try:
  if not is_tokenizers_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .tokenization_herbert_fast import HerbertTokenizerFast

else:
 import sys

 __a     =			_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)



