


'''simple docstring'''
import copy

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


UpperCamelCase__          = logging.get_logger(__name__)

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




class      lowerCamelCase_  (      __a ):
      lowerCAmelCase__							=	'deta'
      lowerCAmelCase__							=	{
          'hidden_size': 'd_model',
          'num_attention_heads': 'encoder_attention_heads',
      }






      def __init__(   self							:       Dict		,		_A							:       str=None		,		_A							:       Any=900		,		_A							:       str=2_048		,		_A							:       str=6		,		_A							:       Optional[Any]=2_048		,		_A							:       int=8		,		_A							:       List[Any]=6		,		_A							:       Optional[Any]=1_024		,		_A							:       Tuple=8		,		_A							:       Optional[int]=0.0		,		_A							:       Optional[Any]=True		,		_A							:       Union[str, Any]="relu"		,		_A							:       List[str]=256		,		_A							:       str=0.1		,		_A							:       Union[str, Any]=0.0		,		_A							:       List[str]=0.0		,		_A							:       int=0.0_2		,		_A							:       Union[str, Any]=1.0		,		_A							:       Dict=True		,		_A							:       Union[str, Any]=False		,		_A							:       Dict="sine"		,		_A							:       Dict=5		,		_A							:       Optional[Any]=4		,		_A							:       Tuple=4		,		_A							:       Optional[Any]=True		,		_A							:       Dict=300		,		_A							:       str=True		,		_A							:       Union[str, Any]=True		,		_A							:       Tuple=1		,		_A							:       List[str]=5		,		_A							:       List[str]=2		,		_A							:       List[Any]=1		,		_A							:       List[Any]=1		,		_A							:       Union[str, Any]=5		,		_A							:       str=2		,		_A							:       Optional[Any]=0.1		,		_A							:       Tuple=0.2_5		,		**_A							:       int		,		):


          '''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(_A		,		_A					):
                  UpperCAmelCase__     :						str						=							backbone_config.pop('''model_type'''					)
                  UpperCAmelCase__     :						str						=							CONFIG_MAPPING[backbone_model_type]
                  UpperCAmelCase__     :						Tuple						=							config_class.from_dict(_A					)

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






      @property
      def lowercase_				(   self							:       Any					):


          '''simple docstring'''


          return self.encoder_attention_heads






      @property
      def lowercase_				(   self							:       str					):


          '''simple docstring'''


          return self.d_model






      def lowercase_				(   self							:       Dict					):


          '''simple docstring'''


          UpperCAmelCase__     :						Dict						=							copy.deepcopy(self.__dict__					)
          UpperCAmelCase__     :						Tuple						=							self.backbone_config.to_dict()
          UpperCAmelCase__     :						str						=							self.__class__.model_type
          return output








from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_UpperCamelCase			:	Any								={
    'configuration_megatron_bert': ['MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MegatronBertConfig'],
}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	_UpperCamelCase			:	Optional[Any]								=[
	    'MEGATRON_BERT_PRETRAINED_MODEL_ARCHIVE_LIST',
	    'MegatronBertForCausalLM',
	    'MegatronBertForMaskedLM',
	    'MegatronBertForMultipleChoice',
	    'MegatronBertForNextSentencePrediction',
	    'MegatronBertForPreTraining',
	    'MegatronBertForQuestionAnswering',
	    'MegatronBertForSequenceClassification',
	    'MegatronBertForTokenClassification',
	    'MegatronBertModel',
	    'MegatronBertPreTrainedModel',
	]

if TYPE_CHECKING:
	from .configuration_megatron_bert import MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, MegatronBertConfig

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_megatron_bert import (
		    MEGATRON_BERT_PRETRAINED_MODEL_ARCHIVE_LIST,
		    MegatronBertForCausalLM,
		    MegatronBertForMaskedLM,
		    MegatronBertForMultipleChoice,
		    MegatronBertForNextSentencePrediction,
		    MegatronBertForPreTraining,
		    MegatronBertForQuestionAnswering,
		    MegatronBertForSequenceClassification,
		    MegatronBertForTokenClassification,
		    MegatronBertModel,
		    MegatronBertPreTrainedModel,
		)

else:
	import sys

	_UpperCamelCase			:	Optional[int]								=_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)



