






import warnings

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


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

_UpperCamelCase			:	Any								={
    '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 						UpperCAmelCase__ (							__snake_case							):
		__snake_case      :       Dict     =   "xlnet"
		__snake_case      :       Optional[Any]     =   ["mems"]
		__snake_case      :       Dict     =   {
		    "n_token": "vocab_size",  # Backward compatibility
		    "hidden_size": "d_model",
		    "num_attention_heads": "n_head",
		    "num_hidden_layers": "n_layer",
		}







		def __init__(					self       ,A__=32000       ,A__=1024       ,A__=24       ,A__=16       ,A__=4096       ,A__="gelu"       ,A__=True       ,A__="bi"       ,A__=0.02       ,A__=1E-12       ,A__=0.1       ,A__=512       ,A__=None       ,A__=True       ,A__=False       ,A__=False       ,A__=-1       ,A__=False       ,A__="last"       ,A__=True       ,A__="tanh"       ,A__=0.1       ,A__=5       ,A__=5       ,A__=5       ,A__=1       ,A__=2       ,**A__       ,):
						_A	:				Dict   =      vocab_size
						_A	:				List[Any]   =      d_model
						_A	:				Optional[int]   =      n_layer
						_A	:				Dict   =      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	:				Any   =      d_model // n_head
						_A	:				Optional[int]   =      ff_activation
						_A	:				Tuple   =      d_inner
						_A	:				Any   =      untie_r
						_A	:				Dict   =      attn_type

						_A	:				Dict   =      initializer_range
						_A	:				str   =      layer_norm_eps

						_A	:				Optional[int]   =      dropout
						_A	:				str   =      mem_len
						_A	:				Any   =      reuse_len
						_A	:				Union[str, Any]   =      bi_data
						_A	:				int   =      clamp_len
						_A	:				Optional[Any]   =      same_length

						_A	:				List[Any]   =      summary_type
						_A	:				Any   =      summary_use_proj
						_A	:				Tuple   =      summary_activation
						_A	:				Optional[int]   =      summary_last_dropout
						_A	:				List[Any]   =      start_n_top
						_A	:				List[str]   =      end_n_top

						_A	:				Any   =      bos_token_id
						_A	:				str   =      pad_token_id
						_A	:				Dict   =      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.'''       ,A_       ,)
										_A	:				int   =      kwargs["""use_cache"""]

						_A	:				List[str]   =      use_mems_eval
						_A	:				int   =      use_mems_train
						super().__init__(pad_token_id=A_       ,bos_token_id=A_       ,eos_token_id=A_       ,**A_		)







		@property
		def  A__      (					self		):
						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  A__      (					self       ,A__		):
						# Message copied from Transformer-XL documentation
						raise NotImplementedError(
						    f"""The model {self.model_type} is one of the few models that has no sequence length limit."""		)







import copy
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


SCREAMING_SNAKE_CASE__					:     Optional[int]       =     logging.get_logger(__name__)

SCREAMING_SNAKE_CASE__					:     Tuple       =     {
    'microsoft/conditional-detr-resnet-50': (
        'https://huggingface.co/microsoft/conditional-detr-resnet-50/resolve/main/config.json'
    ),
}


class 		_SCREAMING_SNAKE_CASE     (						A     ):
     __SCREAMING_SNAKE_CASE     					=    '''conditional_detr'''
     __SCREAMING_SNAKE_CASE     					=    ['''past_key_values''']
     __SCREAMING_SNAKE_CASE     					=    {
         '''hidden_size''': '''d_model''',
         '''num_attention_heads''': '''encoder_attention_heads''',
     }


     def __init__(  self							,					A_=True							,					A_=None							,					A_=3							,					A_=3_00							,					A_=6							,					A_=20_48							,					A_=8							,					A_=6							,					A_=20_48							,					A_=8							,					A_=0.0							,					A_=0.0							,					A_=True							,					A_="relu"							,					A_=2_56							,					A_=0.1							,					A_=0.0							,					A_=0.0							,					A_=0.0_2							,					A_=1.0							,					A_=False							,					A_="sine"							,					A_="resnet50"							,					A_=True							,					A_=False							,					A_=2							,					A_=5							,					A_=2							,					A_=1							,					A_=1							,					A_=2							,					A_=5							,					A_=2							,					A_=0.2_5							,					**A_							,					):
       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		:							int							=     CONFIG_MAPPING["""resnet"""](out_features=["""stage4"""]    )
         elif isinstance(A_							,					A_    ):
           _UpperCAmelCase		:							Tuple							=     backbone_config.get("""model_type"""    )
           _UpperCAmelCase		:							Union[str, Any]							=     CONFIG_MAPPING[backbone_model_type]
           _UpperCAmelCase		:							Optional[Any]							=     config_class.from_dict(A_    )

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


     @property
     def        __snake_case(  self    ):
       return self.encoder_attention_heads


     @property
     def        __snake_case(  self    ):
       return self.d_model




     def        __snake_case(  self    ):
       _UpperCAmelCase		:							List[str]							=     copy.deepcopy(self.__dict__    )
       if self.backbone_config is not None:
         _UpperCAmelCase		:							Optional[int]							=     self.backbone_config.to_dict()
       _UpperCAmelCase		:							Dict							=     self.__class__.model_type
       return output


class 		_SCREAMING_SNAKE_CASE     (						A     ):
     __SCREAMING_SNAKE_CASE     					=    version.parse('''1.11'''     )


     @property
     def        __snake_case(  self    ):
       return OrderedDict(
           [
               ("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""}),
               ("""pixel_mask""", {0: """batch"""}),
           ]    )


     @property
     def        __snake_case(  self    ):
       return 1e-5




     @property
     def        __snake_case(  self    ):
       return 12





