



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


lowerCamelCase__			= logging.get_logger(__name__)

lowerCamelCase__			= {
    """microsoft/table-transformer-detection""": (
        """https://huggingface.co/microsoft/table-transformer-detection/resolve/main/config.json"""
    ),
}






class    SCREAMING_SNAKE_CASE			(							lowerCamelCase__					):
							__lowerCamelCase	:	int    ='table-transformer'
							__lowerCamelCase	:	str    =['past_key_values']
							__lowerCamelCase	:	Tuple    ={
							    'hidden_size': 'd_model',
							    'num_attention_heads': 'encoder_attention_heads',
							}





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

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





							@property
							def 						UpperCamelCase_					(   self		:		Any	):

											'''simple docstring'''
											return self.encoder_attention_heads







							@property
							def 						UpperCamelCase_					(   self		:		Optional[int]	):

											'''simple docstring'''
											return self.d_model






class    SCREAMING_SNAKE_CASE			(							lowerCamelCase__					):
							__lowerCamelCase	:	List[Any]    =version.parse('1.11'					)





							@property
							def 						UpperCamelCase_					(   self		:		Optional[Any]	):

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





							@property
							def 						UpperCamelCase_					(   self		:		List[str]	):

											'''simple docstring'''
											return 1E-5







							@property
							def 						UpperCamelCase_					(   self		:		str	):

											'''simple docstring'''
											return 12





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


lowerCamelCase__			= logging.get_logger(__name__)

lowerCamelCase__			= {
    """alibaba-damo/mgp-str-base""": """https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json""",
}






class    SCREAMING_SNAKE_CASE			(							lowerCamelCase__					):
							__lowerCamelCase	:	Dict    ='mgp-str'





							def __init__(   self		:		Optional[Any]      ,				__lowercase		:		Dict=[32, 128]      ,				__lowercase		:		Tuple=4      ,				__lowercase		:		Optional[Any]=3      ,				__lowercase		:		str=27      ,				__lowercase		:		Any=38      ,				__lowercase		:		str=50257      ,				__lowercase		:		List[str]=30522      ,				__lowercase		:		Tuple=768      ,				__lowercase		:		str=12      ,				__lowercase		:		Optional[Any]=12      ,				__lowercase		:		str=4.0      ,				__lowercase		:		Union[str, Any]=True      ,				__lowercase		:		List[Any]=False      ,				__lowercase		:		Union[str, Any]=1E-5      ,				__lowercase		:		Optional[int]=0.0      ,				__lowercase		:		Dict=0.0      ,				__lowercase		:		Union[str, Any]=0.0      ,				__lowercase		:		List[str]=False      ,				__lowercase		:		List[Any]=0.02      ,				**__lowercase		:		List[Any]      ,				):

											'''simple docstring'''
											super().__init__(**__lowercase	)

											__a       =		image_size
											__a       =		patch_size
											__a       =		num_channels
											__a       =		max_token_length
											__a       =		num_character_labels
											__a       =		num_bpe_labels
											__a       =		num_wordpiece_labels
											__a       =		hidden_size
											__a       =		num_hidden_layers
											__a       =		num_attention_heads
											__a       =		mlp_ratio
											__a       =		distilled
											__a       =		layer_norm_eps
											__a       =		drop_rate
											__a       =		qkv_bias
											__a       =		attn_drop_rate
											__a       =		drop_path_rate
											__a       =		output_aa_attentions
											__a       =		initializer_range
