

import warnings

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


__lowercase				      =						logging.get_logger(__name__)

__lowercase				      =						{
    """xlnet-base-cased""": """https://huggingface.co/xlnet-base-cased/resolve/main/config.json""",
    """xlnet-large-cased""": """https://huggingface.co/xlnet-large-cased/resolve/main/config.json""",
}

class    _lowercase				(					__lowerCamelCase			):
   _lowercase     :       Optional[Any]  					=    'xlnet'
   _lowercase     :       List[Any]  					=    ['mems']
   _lowercase     :       List[str]  					=    {
       'n_token': 'vocab_size',  # Backward compatibility
       'hidden_size': 'd_model',
       'num_attention_heads': 'n_head',
       'num_hidden_layers': 'n_layer',
   }

   def __init__(				self	:    Any			,						lowerCamelCase__	:    Union[str, Any]=3_2_0_0_0			,						lowerCamelCase__	:    List[str]=1_0_2_4			,						lowerCamelCase__	:    Tuple=2_4			,						lowerCamelCase__	:    Optional[Any]=1_6			,						lowerCamelCase__	:    Optional[int]=4_0_9_6			,						lowerCamelCase__	:    int="gelu"			,						lowerCamelCase__	:    str=True			,						lowerCamelCase__	:    Dict="bi"			,						lowerCamelCase__	:    Union[str, Any]=0.02			,						lowerCamelCase__	:    Union[str, Any]=1e-12			,						lowerCamelCase__	:    Union[str, Any]=0.1			,						lowerCamelCase__	:    Optional[int]=5_1_2			,						lowerCamelCase__	:    Optional[Any]=None			,						lowerCamelCase__	:    int=True			,						lowerCamelCase__	:    Optional[int]=False			,						lowerCamelCase__	:    Dict=False			,						lowerCamelCase__	:    Dict=-1			,						lowerCamelCase__	:    Any=False			,						lowerCamelCase__	:    Any="last"			,						lowerCamelCase__	:    Dict=True			,						lowerCamelCase__	:    Optional[Any]="tanh"			,						lowerCamelCase__	:    Tuple=0.1			,						lowerCamelCase__	:    List[str]=5			,						lowerCamelCase__	:    Optional[Any]=5			,						lowerCamelCase__	:    List[str]=5			,						lowerCamelCase__	:    int=1			,						lowerCamelCase__	:    List[Any]=2			,						**lowerCamelCase__	:    Union[str, Any]			,						) ->			Union[str, Any]:
         """simple docstring"""





         A_							       =		vocab_size
         A_							       =		d_model
         A_							       =		n_layer
         A_							       =		n_head
         if d_model % n_head != 0:
               raise ValueError(F"'d_model % n_head' ({d_model % n_head}) should be equal to 0"       )
         if "d_head" in kwargs:
               if kwargs["d_head"] != d_model // n_head:
                     raise ValueError(
                         F"`d_head` ({kwargs['d_head']}) should be equal to `d_model // n_head` ({d_model // n_head})"       )
         A_							       =		d_model // n_head
         A_							       =		ff_activation
         A_							       =		d_inner
         A_							       =		untie_r
         A_							       =		attn_type

         A_							       =		initializer_range
         A_							       =		layer_norm_eps

         A_							       =		dropout
         A_							       =		mem_len
         A_							       =		reuse_len
         A_							       =		bi_data
         A_							       =		clamp_len
         A_							       =		same_length

         A_							       =		summary_type
         A_							       =		summary_use_proj
         A_							       =		summary_activation
         A_							       =		summary_last_dropout
         A_							       =		start_n_top
         A_							       =		end_n_top

         A_							       =		bos_token_id
         A_							       =		pad_token_id
         A_							       =		eos_token_id

         if "use_cache" in kwargs:
               warnings.warn(
                   '''The `use_cache` argument is deprecated and will be removed in a future version, use `use_mems_eval`'''
                   ''' instead.'''			,						lowerCamelCase__			,						)
               A_							       =		kwargs['''use_cache''']

         A_							       =		use_mems_eval
         A_							       =		use_mems_train
         super().__init__(pad_token_id=lowerCamelCase__			,						bos_token_id=lowerCamelCase__			,						eos_token_id=lowerCamelCase__			,						**lowerCamelCase__       )

   @property
   def     UpperCamelCase					(				self	:    List[Any]       ) ->			List[Any]:
         """simple docstring"""





         logger.info(F"The model {self.model_type} is one of the few models that has no sequence length limit."       )
         return -1





   @max_position_embeddings.setter
   def     UpperCamelCase					(				self	:    int			,						lowerCamelCase__	:    Tuple       ) ->			List[str]:
         """simple docstring"""





         raise NotImplementedError(
             F"The model {self.model_type} is one of the few models that has no sequence length limit."       )








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


__lowercase				      =						logging.get_logger(__name__)

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

class    _lowercase				(					__lowerCamelCase			):
   _lowercase     :       Any  					=    'table-transformer'
   _lowercase     :       List[Any]  					=    ['past_key_values']
   _lowercase     :       Union[str, Any]  					=    {
       'hidden_size': 'd_model',
       'num_attention_heads': 'encoder_attention_heads',
   }

   def __init__(				self	:    List[Any]			,						lowerCamelCase__	:    Any=True			,						lowerCamelCase__	:    List[Any]=None			,						lowerCamelCase__	:    Any=3			,						lowerCamelCase__	:    Any=1_0_0			,						lowerCamelCase__	:    int=6			,						lowerCamelCase__	:    List[Any]=2_0_4_8			,						lowerCamelCase__	:    List[str]=8			,						lowerCamelCase__	:    int=6			,						lowerCamelCase__	:    List[str]=2_0_4_8			,						lowerCamelCase__	:    Optional[int]=8			,						lowerCamelCase__	:    Union[str, Any]=0.0			,						lowerCamelCase__	:    Any=0.0			,						lowerCamelCase__	:    str=True			,						lowerCamelCase__	:    Optional[Any]="relu"			,						lowerCamelCase__	:    Optional[int]=2_5_6			,						lowerCamelCase__	:    List[str]=0.1			,						lowerCamelCase__	:    str=0.0			,						lowerCamelCase__	:    Optional[int]=0.0			,						lowerCamelCase__	:    Dict=0.02			,						lowerCamelCase__	:    Union[str, Any]=1.0			,						lowerCamelCase__	:    Union[str, Any]=False			,						lowerCamelCase__	:    Optional[int]="sine"			,						lowerCamelCase__	:    str="resnet50"			,						lowerCamelCase__	:    List[str]=True			,						lowerCamelCase__	:    Optional[Any]=False			,						lowerCamelCase__	:    Any=1			,						lowerCamelCase__	:    int=5			,						lowerCamelCase__	:    Union[str, Any]=2			,						lowerCamelCase__	:    List[str]=1			,						lowerCamelCase__	:    Union[str, Any]=1			,						lowerCamelCase__	:    Optional[Any]=5			,						lowerCamelCase__	:    Tuple=2			,						lowerCamelCase__	:    List[str]=0.1			,						**lowerCamelCase__	:    List[str]			,						) ->			Dict:
         """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(lowerCamelCase__			,						lowerCamelCase__       ):
                     A_							       =		backbone_config.get('''model_type'''       )
                     A_							       =		CONFIG_MAPPING[backbone_model_type]
                     A_							       =		config_class.from_dict(lowerCamelCase__       )
               # 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=lowerCamelCase__			,						**lowerCamelCase__       )

   @property
   def     UpperCamelCase					(				self	:    Optional[Any]       ) ->			int:
         """simple docstring"""





         return self.encoder_attention_heads





   @property
   def     UpperCamelCase					(				self	:    Any       ) ->			int:
         """simple docstring"""





         return self.d_model



class    _lowercase				(					__lowerCamelCase			):
   _lowercase     :       Tuple  					=    version.parse('1.11'			)

   @property
   def     UpperCamelCase					(				self	:    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	:    List[Any]       ) ->			float:
         """simple docstring"""





         return 1e-5





   @property
   def     UpperCamelCase					(				self	:    List[Any]       ) ->			int:
         """simple docstring"""





         return 1_2





