






import copy
from collections import OrderedDict
from typing import Dict, Mapping

from packaging import version

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


_a      	=  logging.get_logger(__name__)

_a      	=  {
    '''facebook/detr-resnet-50''': '''https://huggingface.co/facebook/detr-resnet-50/resolve/main/config.json''',
    # See all DETR models at https://huggingface.co/models?filter=detr
}





class __lowerCamelCase (      snake_case__):





	"""simple docstring"""






	UpperCamelCase__								=      "detr"
	UpperCamelCase__								=      ["past_key_values"]
	UpperCamelCase__								=      {
	    "hidden_size": "d_model",
	    "num_attention_heads": "encoder_attention_heads",
	}

	def __init__(							self       ,    UpperCAmelCase=True       ,    UpperCAmelCase=None       ,    UpperCAmelCase=3       ,    UpperCAmelCase=100       ,    UpperCAmelCase=6       ,    UpperCAmelCase=2048       ,    UpperCAmelCase=8       ,    UpperCAmelCase=6       ,    UpperCAmelCase=2048       ,    UpperCAmelCase=8       ,    UpperCAmelCase=0.0       ,    UpperCAmelCase=0.0       ,    UpperCAmelCase=True       ,    UpperCAmelCase="relu"       ,    UpperCAmelCase=256       ,    UpperCAmelCase=0.1       ,    UpperCAmelCase=0.0       ,    UpperCAmelCase=0.0       ,    UpperCAmelCase=0.02       ,    UpperCAmelCase=1.0       ,    UpperCAmelCase=False       ,    UpperCAmelCase="sine"       ,    UpperCAmelCase="resnet50"       ,    UpperCAmelCase=True       ,    UpperCAmelCase=False       ,    UpperCAmelCase=1       ,    UpperCAmelCase=5       ,    UpperCAmelCase=2       ,    UpperCAmelCase=1       ,    UpperCAmelCase=1       ,    UpperCAmelCase=5       ,    UpperCAmelCase=2       ,    UpperCAmelCase=0.1       ,    **UpperCAmelCase       ,    ):
							"""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(UpperCAmelCase       ,    UpperCAmelCase    ):
																			_UpperCAmelCase									=			backbone_config.get('model_type'    )
																			_UpperCAmelCase									=			CONFIG_MAPPING[backbone_model_type]
																			_UpperCAmelCase									=			config_class.from_dict(UpperCAmelCase    )
													# set timm attributes to None
													_UpperCAmelCase					, _UpperCAmelCase					, _UpperCAmelCase									=			None, None, None

							_UpperCAmelCase									=			use_timm_backbone
							_UpperCAmelCase									=			backbone_config
							_UpperCAmelCase									=			num_channels
							_UpperCAmelCase									=			num_queries
							_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									=			decoder_layerdrop
							_UpperCAmelCase									=			encoder_layers
							_UpperCAmelCase									=			auxiliary_loss
							_UpperCAmelCase									=			position_embedding_type
							_UpperCAmelCase									=			backbone
							_UpperCAmelCase									=			use_pretrained_backbone
							_UpperCAmelCase									=			dilation
							# 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
							super().__init__(is_encoder_decoder=UpperCAmelCase       ,    **UpperCAmelCase    )

	@property
	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							return self.encoder_attention_heads

	@property
	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							return self.d_model

	@classmethod
	def        UpperCamelCase    (							cls       ,    UpperCAmelCase       ,    **UpperCAmelCase    ):
							"""simple docstring"""







							return cls(backbone_config=UpperCAmelCase       ,    **UpperCAmelCase    )

	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							_UpperCAmelCase									=			copy.deepcopy(self.__dict__    )
							if output["backbone_config"] is not None:
													_UpperCAmelCase									=			self.backbone_config.to_dict()
							_UpperCAmelCase									=			self.__class__.model_type
							return output





class __lowerCamelCase (      snake_case__):





	"""simple docstring"""






	UpperCamelCase__								=      version.parse("1.11")

	@property
	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							return OrderedDict(
							    [
							        ('pixel_values', {0: 'batch', 1: 'num_channels', 2: 'height', 3: 'width'}),
							        ('pixel_mask', {0: 'batch'}),
							    ]    )

	@property
	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							return 1e-5

	@property
	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							return 12








from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


_a      	=  logging.get_logger(__name__)

_a      	=  {
    '''distilbert-base-uncased''': '''https://huggingface.co/distilbert-base-uncased/resolve/main/config.json''',
    '''distilbert-base-uncased-distilled-squad''': (
        '''https://huggingface.co/distilbert-base-uncased-distilled-squad/resolve/main/config.json'''
    ),
    '''distilbert-base-cased''': '''https://huggingface.co/distilbert-base-cased/resolve/main/config.json''',
    '''distilbert-base-cased-distilled-squad''': (
        '''https://huggingface.co/distilbert-base-cased-distilled-squad/resolve/main/config.json'''
    ),
    '''distilbert-base-german-cased''': '''https://huggingface.co/distilbert-base-german-cased/resolve/main/config.json''',
    '''distilbert-base-multilingual-cased''': (
        '''https://huggingface.co/distilbert-base-multilingual-cased/resolve/main/config.json'''
    ),
    '''distilbert-base-uncased-finetuned-sst-2-english''': (
        '''https://huggingface.co/distilbert-base-uncased-finetuned-sst-2-english/resolve/main/config.json'''
    ),
}





class __lowerCamelCase (      snake_case__):





	"""simple docstring"""






	UpperCamelCase__								=      "distilbert"
	UpperCamelCase__								=      {
	    "hidden_size": "dim",
	    "num_attention_heads": "n_heads",
	    "num_hidden_layers": "n_layers",
	}

	def __init__(							self       ,    UpperCAmelCase=3_0522       ,    UpperCAmelCase=512       ,    UpperCAmelCase=False       ,    UpperCAmelCase=6       ,    UpperCAmelCase=12       ,    UpperCAmelCase=768       ,    UpperCAmelCase=4 * 768       ,    UpperCAmelCase=0.1       ,    UpperCAmelCase=0.1       ,    UpperCAmelCase="gelu"       ,    UpperCAmelCase=0.02       ,    UpperCAmelCase=0.1       ,    UpperCAmelCase=0.2       ,    UpperCAmelCase=0       ,    **UpperCAmelCase       ,    ):
							"""simple docstring"""







							_UpperCAmelCase									=			vocab_size
							_UpperCAmelCase									=			max_position_embeddings
							_UpperCAmelCase									=			sinusoidal_pos_embds
							_UpperCAmelCase									=			n_layers
							_UpperCAmelCase									=			n_heads
							_UpperCAmelCase									=			dim
							_UpperCAmelCase									=			hidden_dim
							_UpperCAmelCase									=			dropout
							_UpperCAmelCase									=			attention_dropout
							_UpperCAmelCase									=			activation
							_UpperCAmelCase									=			initializer_range
							_UpperCAmelCase									=			qa_dropout
							_UpperCAmelCase									=			seq_classif_dropout
							super().__init__(**UpperCAmelCase       ,    pad_token_id=UpperCAmelCase    )





class __lowerCamelCase (      snake_case__):





	"""simple docstring"""






	@property
	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							if self.task == "multiple-choice":
													_UpperCAmelCase									=			{0: 'batch', 1: 'choice', 2: 'sequence'}
							else:
													_UpperCAmelCase									=			{0: 'batch', 1: 'sequence'}
							return OrderedDict(
							    [
							        ('input_ids', dynamic_axis),
							        ('attention_mask', dynamic_axis),
							    ]    )
