




"""simple docstring"""

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


_lowerCamelCase  :			Tuple        =       logging.get_logger(__name__)

_lowerCamelCase  :			List[str]        =       {
    '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        lowercase      (    __UpperCAmelCase):
				__lowerCAmelCase    :    Tuple         =   """detr"""
				__lowerCAmelCase    :    List[Any]         =   ["""past_key_values"""]
				__lowerCAmelCase    :    Optional[Any]         =   {
				    """hidden_size""": """d_model""",
				    """num_attention_heads""": """encoder_attention_heads""",
				}







				def __init__(							self   :					Union[str, Any]      ,     _lowerCamelCase   :					Optional[Any]=True      ,     _lowerCamelCase   :					List[str]=None      ,     _lowerCamelCase   :					Union[str, Any]=3      ,     _lowerCamelCase   :					Optional[Any]=1_00      ,     _lowerCamelCase   :					Dict=6      ,     _lowerCamelCase   :					Optional[Any]=20_48      ,     _lowerCamelCase   :					List[str]=8      ,     _lowerCamelCase   :					Optional[int]=6      ,     _lowerCamelCase   :					Tuple=20_48      ,     _lowerCamelCase   :					Optional[int]=8      ,     _lowerCamelCase   :					Tuple=0.0      ,     _lowerCamelCase   :					List[str]=0.0      ,     _lowerCamelCase   :					Tuple=True      ,     _lowerCamelCase   :					Dict="relu"      ,     _lowerCamelCase   :					Union[str, Any]=2_56      ,     _lowerCamelCase   :					str=0.1      ,     _lowerCamelCase   :					Optional[int]=0.0      ,     _lowerCamelCase   :					int=0.0      ,     _lowerCamelCase   :					Optional[int]=0.02      ,     _lowerCamelCase   :					List[str]=1.0      ,     _lowerCamelCase   :					Optional[int]=False      ,     _lowerCamelCase   :					Tuple="sine"      ,     _lowerCamelCase   :					Union[str, Any]="resnet50"      ,     _lowerCamelCase   :					Tuple=True      ,     _lowerCamelCase   :					List[Any]=False      ,     _lowerCamelCase   :					Optional[int]=1      ,     _lowerCamelCase   :					List[str]=5      ,     _lowerCamelCase   :					Union[str, Any]=2      ,     _lowerCamelCase   :					str=1      ,     _lowerCamelCase   :					Union[str, Any]=1      ,     _lowerCamelCase   :					List[Any]=5      ,     _lowerCamelCase   :					Any=2      ,     _lowerCamelCase   :					Dict=0.1      ,     **_lowerCamelCase   :					int      ,     ):



					"""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_  :				Dict	   =		CONFIG_MAPPING['''resnet'''](out_features=['''stage4''']       )
						elif isinstance(_lowerCamelCase      ,     _lowerCamelCase       ):
							A_  :				List[Any]	   =		backbone_config.get('''model_type'''       )
							A_  :				Union[str, Any]	   =		CONFIG_MAPPING[backbone_model_type]
							A_  :				int	   =		config_class.from_dict(_lowerCamelCase       )
						# set timm attributes to None
						A_   , A_   , A_  :				List[str]	   =		None, None, None

					A_  :				Any	   =		use_timm_backbone
					A_  :				int	   =		backbone_config
					A_  :				Optional[Any]	   =		num_channels
					A_  :				Any	   =		num_queries
					A_  :				Tuple	   =		d_model
					A_  :				Optional[Any]	   =		encoder_ffn_dim
					A_  :				int	   =		encoder_layers
					A_  :				Optional[int]	   =		encoder_attention_heads
					A_  :				Dict	   =		decoder_ffn_dim
					A_  :				List[str]	   =		decoder_layers
					A_  :				List[str]	   =		decoder_attention_heads
					A_  :				List[Any]	   =		dropout
					A_  :				Any	   =		attention_dropout
					A_  :				str	   =		activation_dropout
					A_  :				str	   =		activation_function
					A_  :				Tuple	   =		init_std
					A_  :				Any	   =		init_xavier_std
					A_  :				Union[str, Any]	   =		encoder_layerdrop
					A_  :				Tuple	   =		decoder_layerdrop
					A_  :				Optional[Any]	   =		encoder_layers
					A_  :				Union[str, Any]	   =		auxiliary_loss
					A_  :				List[Any]	   =		position_embedding_type
					A_  :				Optional[Any]	   =		backbone
					A_  :				Union[str, Any]	   =		use_pretrained_backbone
					A_  :				List[Any]	   =		dilation
					# Hungarian matcher
					A_  :				Any	   =		class_cost
					A_  :				Optional[int]	   =		bbox_cost
					A_  :				str	   =		giou_cost
					# Loss coefficients
					A_  :				List[Any]	   =		mask_loss_coefficient
					A_  :				Tuple	   =		dice_loss_coefficient
					A_  :				Any	   =		bbox_loss_coefficient
					A_  :				List[str]	   =		giou_loss_coefficient
					A_  :				Union[str, Any]	   =		eos_coefficient
					super().__init__(is_encoder_decoder=_lowerCamelCase      ,     **_lowerCamelCase       )







				@property
				def 					a_  (							self   :					Union[str, Any]       ):



					"""simple docstring"""

					return self.encoder_attention_heads







				@property
				def 					a_  (							self   :					Dict       ):



					"""simple docstring"""

					return self.d_model







				@classmethod
				def 					a_  (							cls   :					Optional[int]      ,     _lowerCamelCase   :					PretrainedConfig      ,     **_lowerCamelCase   :					Dict       ):



					"""simple docstring"""

					return cls(backbone_config=_lowerCamelCase      ,     **_lowerCamelCase       )







				def 					a_  (							self   :					Dict       ):



					"""simple docstring"""

					A_  :				Union[str, Any]	   =		copy.deepcopy(self.__dict__       )
					if output["backbone_config"] is not None:
						A_  :				Optional[Any]	   =		self.backbone_config.to_dict()
					A_  :				str	   =		self.__class__.model_type
					return output

class        lowercase      (    __UpperCAmelCase):
				__lowerCAmelCase    :    Union[str, Any]         =   version.parse("""1.11""")







				@property
				def 					a_  (							self   :					Dict       ):



					"""simple docstring"""

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







				@property
				def 					a_  (							self   :					List[Any]       ):



					"""simple docstring"""

					return 1E-5







				@property
				def 					a_  (							self   :					str       ):



					"""simple docstring"""

					return 12











"""simple docstring"""

from ...configuration_utils import PretrainedConfig
from ...utils import logging


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

_lowerCamelCase  :			Any        =       {
    'studio-ousia/luke-base': 'https://huggingface.co/studio-ousia/luke-base/resolve/main/config.json',
    'studio-ousia/luke-large': 'https://huggingface.co/studio-ousia/luke-large/resolve/main/config.json',
}

class        lowercase      (    __UpperCAmelCase):
				__lowerCAmelCase    :    Any         =   """luke"""







				def __init__(							self   :					List[str]      ,     _lowerCamelCase   :					Union[str, Any]=5_02_67      ,     _lowerCamelCase   :					Tuple=50_00_00      ,     _lowerCamelCase   :					int=7_68      ,     _lowerCamelCase   :					Union[str, Any]=2_56      ,     _lowerCamelCase   :					Dict=12      ,     _lowerCamelCase   :					str=12      ,     _lowerCamelCase   :					Dict=30_72      ,     _lowerCamelCase   :					Union[str, Any]="gelu"      ,     _lowerCamelCase   :					Optional[int]=0.1      ,     _lowerCamelCase   :					str=0.1      ,     _lowerCamelCase   :					Union[str, Any]=5_12      ,     _lowerCamelCase   :					int=2      ,     _lowerCamelCase   :					Optional[int]=0.02      ,     _lowerCamelCase   :					int=1E-12      ,     _lowerCamelCase   :					List[str]=True      ,     _lowerCamelCase   :					str=None      ,     _lowerCamelCase   :					Union[str, Any]=1      ,     _lowerCamelCase   :					str=0      ,     _lowerCamelCase   :					Dict=2      ,     **_lowerCamelCase   :					Optional[int]      ,     ):



					"""simple docstring"""

					super().__init__(pad_token_id=_lowerCamelCase      ,     bos_token_id=_lowerCamelCase      ,     eos_token_id=_lowerCamelCase      ,     **_lowerCamelCase       )

					A_  :				str	   =		vocab_size
					A_  :				Optional[Any]	   =		entity_vocab_size
					A_  :				Optional[Any]	   =		hidden_size
					A_  :				List[str]	   =		entity_emb_size
					A_  :				Union[str, Any]	   =		num_hidden_layers
					A_  :				Dict	   =		num_attention_heads
					A_  :				Union[str, Any]	   =		hidden_act
					A_  :				Dict	   =		intermediate_size
					A_  :				int	   =		hidden_dropout_prob
					A_  :				str	   =		attention_probs_dropout_prob
					A_  :				List[Any]	   =		max_position_embeddings
					A_  :				Optional[Any]	   =		type_vocab_size
					A_  :				Optional[int]	   =		initializer_range
					A_  :				str	   =		layer_norm_eps
					A_  :				List[str]	   =		use_entity_aware_attention
					A_  :				Optional[int]	   =		classifier_dropout





