
"""simple docstring"""




import copy

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


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

a		:       Optional[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     lowercase(a_       ):
     __snake_case:	Dict						=     '''deformable_detr'''
     __snake_case:	List[str]						=     {
         '''hidden_size''': '''d_model''',
         '''num_attention_heads''': '''encoder_attention_heads''',
     }



     def __init__(							self     ,				__SCREAMING_SNAKE_CASE=True     ,				__SCREAMING_SNAKE_CASE=None     ,				__SCREAMING_SNAKE_CASE=3     ,				__SCREAMING_SNAKE_CASE=3_0_0     ,				__SCREAMING_SNAKE_CASE=1_0_2_4     ,				__SCREAMING_SNAKE_CASE=6     ,				__SCREAMING_SNAKE_CASE=1_0_2_4     ,				__SCREAMING_SNAKE_CASE=8     ,				__SCREAMING_SNAKE_CASE=6     ,				__SCREAMING_SNAKE_CASE=1_0_2_4     ,				__SCREAMING_SNAKE_CASE=8     ,				__SCREAMING_SNAKE_CASE=0.0     ,				__SCREAMING_SNAKE_CASE=True     ,				__SCREAMING_SNAKE_CASE="relu"     ,				__SCREAMING_SNAKE_CASE=2_5_6     ,				__SCREAMING_SNAKE_CASE=0.1     ,				__SCREAMING_SNAKE_CASE=0.0     ,				__SCREAMING_SNAKE_CASE=0.0     ,				__SCREAMING_SNAKE_CASE=0.02     ,				__SCREAMING_SNAKE_CASE=1.0     ,				__SCREAMING_SNAKE_CASE=True     ,				__SCREAMING_SNAKE_CASE=False     ,				__SCREAMING_SNAKE_CASE="sine"     ,				__SCREAMING_SNAKE_CASE="resnet50"     ,				__SCREAMING_SNAKE_CASE=True     ,				__SCREAMING_SNAKE_CASE=False     ,				__SCREAMING_SNAKE_CASE=4     ,				__SCREAMING_SNAKE_CASE=4     ,				__SCREAMING_SNAKE_CASE=4     ,				__SCREAMING_SNAKE_CASE=False     ,				__SCREAMING_SNAKE_CASE=3_0_0     ,				__SCREAMING_SNAKE_CASE=False     ,				__SCREAMING_SNAKE_CASE=1     ,				__SCREAMING_SNAKE_CASE=5     ,				__SCREAMING_SNAKE_CASE=2     ,				__SCREAMING_SNAKE_CASE=1     ,				__SCREAMING_SNAKE_CASE=1     ,				__SCREAMING_SNAKE_CASE=5     ,				__SCREAMING_SNAKE_CASE=2     ,				__SCREAMING_SNAKE_CASE=0.1     ,				__SCREAMING_SNAKE_CASE=0.25     ,				__SCREAMING_SNAKE_CASE=False     ,				**__SCREAMING_SNAKE_CASE     ,				)		->     List[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(lowerCAmelCase_     ,				lowerCAmelCase_   ):
                 a__		=			backbone_config.get('model_type'   )
                 a__		=			CONFIG_MAPPING[backbone_model_type]
                 a__		=			config_class.from_dict(lowerCAmelCase_   )
         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=lowerCAmelCase_     ,				**lowerCAmelCase_   )



     @property
     def 			lowercase__  (							self   )		->     int:







         """simple docstring"""



         return self.encoder_attention_heads



     @property
     def 			lowercase__  (							self   )		->     int:







         """simple docstring"""



         return self.d_model




     def 			lowercase__  (							self   )		->     int:







         """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'''





from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_speech_available,
    is_torch_available,
)


UpperCAmelCase__  			=				{
    '''configuration_trocr''': ['''TROCR_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TrOCRConfig'''],
    '''processing_trocr''': ['''TrOCRProcessor'''],
}


try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					UpperCAmelCase__  			=				[
					    '''TROCR_PRETRAINED_MODEL_ARCHIVE_LIST''',
					    '''TrOCRForCausalLM''',
					    '''TrOCRPreTrainedModel''',
					]


if TYPE_CHECKING:
					from .configuration_trocr import TROCR_PRETRAINED_CONFIG_ARCHIVE_MAP, TrOCRConfig
					from .processing_trocr import TrOCRProcessor

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_trocr import TROCR_PRETRAINED_MODEL_ARCHIVE_LIST, TrOCRForCausalLM, TrOCRPreTrainedModel

else:
					import sys

					UpperCAmelCase__  			=				_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)



