


from collections import OrderedDict
from typing import Mapping

from packaging import version

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


snake_case_						:			List[Any]													=							logging.get_logger(__name__)

snake_case_						:			Union[str, Any]													=							{
    '''microsoft/table-transformer-detection''': (
        '''https://huggingface.co/microsoft/table-transformer-detection/resolve/main/config.json'''
    ),
}

class 						A__							(		UpperCamelCase__  ):
						UpperCAmelCase             =						"table-transformer"
						UpperCAmelCase             =						["past_key_values"]
						UpperCAmelCase             =						{
						    "hidden_size": "d_model",
						    "num_attention_heads": "encoder_attention_heads",
						}




						def __init__(       self					:      str				,    _a					:      Union[str, Any]=True				,    _a					:      Any=None				,    _a					:      Union[str, Any]=3				,    _a					:      int=100				,    _a					:      List[str]=6				,    _a					:      str=2048				,    _a					:      Any=8				,    _a					:      Tuple=6				,    _a					:      Any=2048				,    _a					:      List[str]=8				,    _a					:      Dict=0.0				,    _a					:      List[str]=0.0				,    _a					:      Union[str, Any]=True				,    _a					:      List[Any]="relu"				,    _a					:      List[Any]=256				,    _a					:      Any=0.1				,    _a					:      List[str]=0.0				,    _a					:      Optional[Any]=0.0				,    _a					:      List[Any]=0.02				,    _a					:      Tuple=1.0				,    _a					:      List[str]=False				,    _a					:      List[Any]="sine"				,    _a					:      Optional[Any]="resnet50"				,    _a					:      int=True				,    _a					:      List[str]=False				,    _a					:      List[str]=1				,    _a					:      Tuple=5				,    _a					:      Dict=2				,    _a					:      Union[str, Any]=1				,    _a					:      Tuple=1				,    _a					:      Union[str, Any]=5				,    _a					:      Dict=2				,    _a					:      Optional[Any]=0.1				,    **_a					:      Optional[Any]				,    )							->     Union[str, 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.'''  )
																		_SCREAMING_SNAKE_CASE			  =CONFIG_MAPPING['''resnet'''](out_features=['''stage4''']  )
														elif isinstance(_a				,    _a  ):
																		_SCREAMING_SNAKE_CASE			  =backbone_config.get('''model_type'''  )
																		_SCREAMING_SNAKE_CASE			  =CONFIG_MAPPING[backbone_model_type]
																		_SCREAMING_SNAKE_CASE			  =config_class.from_dict(_a  )
														# set timm attributes to None
														_SCREAMING_SNAKE_CASE  ,				_SCREAMING_SNAKE_CASE  ,				_SCREAMING_SNAKE_CASE			  =None, None, None

										_SCREAMING_SNAKE_CASE			  =use_timm_backbone
										_SCREAMING_SNAKE_CASE			  =backbone_config
										_SCREAMING_SNAKE_CASE			  =num_channels
										_SCREAMING_SNAKE_CASE			  =num_queries
										_SCREAMING_SNAKE_CASE			  =d_model
										_SCREAMING_SNAKE_CASE			  =encoder_ffn_dim
										_SCREAMING_SNAKE_CASE			  =encoder_layers
										_SCREAMING_SNAKE_CASE			  =encoder_attention_heads
										_SCREAMING_SNAKE_CASE			  =decoder_ffn_dim
										_SCREAMING_SNAKE_CASE			  =decoder_layers
										_SCREAMING_SNAKE_CASE			  =decoder_attention_heads
										_SCREAMING_SNAKE_CASE			  =dropout
										_SCREAMING_SNAKE_CASE			  =attention_dropout
										_SCREAMING_SNAKE_CASE			  =activation_dropout
										_SCREAMING_SNAKE_CASE			  =activation_function
										_SCREAMING_SNAKE_CASE			  =init_std
										_SCREAMING_SNAKE_CASE			  =init_xavier_std
										_SCREAMING_SNAKE_CASE			  =encoder_layerdrop
										_SCREAMING_SNAKE_CASE			  =decoder_layerdrop
										_SCREAMING_SNAKE_CASE			  =encoder_layers
										_SCREAMING_SNAKE_CASE			  =auxiliary_loss
										_SCREAMING_SNAKE_CASE			  =position_embedding_type
										_SCREAMING_SNAKE_CASE			  =backbone
										_SCREAMING_SNAKE_CASE			  =use_pretrained_backbone
										_SCREAMING_SNAKE_CASE			  =dilation
										# Hungarian matcher
										_SCREAMING_SNAKE_CASE			  =class_cost
										_SCREAMING_SNAKE_CASE			  =bbox_cost
										_SCREAMING_SNAKE_CASE			  =giou_cost
										# Loss coefficients
										_SCREAMING_SNAKE_CASE			  =mask_loss_coefficient
										_SCREAMING_SNAKE_CASE			  =dice_loss_coefficient
										_SCREAMING_SNAKE_CASE			  =bbox_loss_coefficient
										_SCREAMING_SNAKE_CASE			  =giou_loss_coefficient
										_SCREAMING_SNAKE_CASE			  =eos_coefficient
										super().__init__(is_encoder_decoder=_a				,    **_a  )




						@property
						def 							__UpperCamelCase				(       self					:      Union[str, Any]  )							->     int:


										"""simple docstring"""





										return self.encoder_attention_heads




						@property
						def 							__UpperCamelCase				(       self					:      int  )							->     int:


										"""simple docstring"""





										return self.d_model

class 						A__							(		UpperCamelCase__  ):
						UpperCAmelCase             =						version.parse("1.11"  )




						@property
						def 							__UpperCamelCase				(       self					:      Optional[Any]  )							->     Mapping[str, Mapping[int, str]]:


										"""simple docstring"""





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




						@property
						def 							__UpperCamelCase				(       self					:      Optional[Any]  )							->     float:


										"""simple docstring"""





										return 1E-5




						@property
						def 							__UpperCamelCase				(       self					:      List[Any]  )							->     int:


										"""simple docstring"""





										return 12



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


snake_case_						:			int													=							logging.get_logger(__name__)

snake_case_						:			Optional[Any]													=							{
    '''SCUT-DLVCLab/lilt-roberta-en-base''': (
        '''https://huggingface.co/SCUT-DLVCLab/lilt-roberta-en-base/resolve/main/config.json'''
    ),
}

class 						A__							(		UpperCamelCase__  ):
						UpperCAmelCase             =						"lilt"




						def __init__(       self					:      int				,    _a					:      Dict=3_0522				,    _a					:      str=768				,    _a					:      Optional[int]=12				,    _a					:      str=12				,    _a					:      List[str]=3072				,    _a					:      Any="gelu"				,    _a					:      int=0.1				,    _a					:      Any=0.1				,    _a					:      Union[str, Any]=512				,    _a					:      str=2				,    _a					:      List[Any]=0.02				,    _a					:      str=1E-12				,    _a					:      str=0				,    _a					:      str="absolute"				,    _a					:      Any=None				,    _a					:      Dict=4				,    _a					:      int=1024				,    **_a					:      List[Any]				,    )							->     Any:


										"""simple docstring"""





										super().__init__(pad_token_id=_a				,    **_a  )

										_SCREAMING_SNAKE_CASE			  =vocab_size
										_SCREAMING_SNAKE_CASE			  =hidden_size
										_SCREAMING_SNAKE_CASE			  =num_hidden_layers
										_SCREAMING_SNAKE_CASE			  =num_attention_heads
										_SCREAMING_SNAKE_CASE			  =hidden_act
										_SCREAMING_SNAKE_CASE			  =intermediate_size
										_SCREAMING_SNAKE_CASE			  =hidden_dropout_prob
										_SCREAMING_SNAKE_CASE			  =attention_probs_dropout_prob
										_SCREAMING_SNAKE_CASE			  =max_position_embeddings
										_SCREAMING_SNAKE_CASE			  =type_vocab_size
										_SCREAMING_SNAKE_CASE			  =initializer_range
										_SCREAMING_SNAKE_CASE			  =layer_norm_eps
										_SCREAMING_SNAKE_CASE			  =position_embedding_type
										_SCREAMING_SNAKE_CASE			  =classifier_dropout
										_SCREAMING_SNAKE_CASE			  =channel_shrink_ratio
										_SCREAMING_SNAKE_CASE			  =max_ad_position_embeddings