


from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


__UpperCamelCase    :						Any     =							{
    'configuration_transfo_xl': ['TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TransfoXLConfig'],
    'tokenization_transfo_xl': ['TransfoXLCorpus', 'TransfoXLTokenizer'],
}

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __UpperCamelCase    :						Tuple     =							[
        'TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST',
        'AdaptiveEmbedding',
        'TransfoXLForSequenceClassification',
        'TransfoXLLMHeadModel',
        'TransfoXLModel',
        'TransfoXLPreTrainedModel',
        'load_tf_weights_in_transfo_xl',
    ]

try:
    if not is_tf_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __UpperCamelCase    :						Optional[Any]     =							[
        'TF_TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST',
        'TFAdaptiveEmbedding',
        'TFTransfoXLForSequenceClassification',
        'TFTransfoXLLMHeadModel',
        'TFTransfoXLMainLayer',
        'TFTransfoXLModel',
        'TFTransfoXLPreTrainedModel',
    ]


if TYPE_CHECKING:
    from .configuration_transfo_xl import TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP, TransfoXLConfig
    from .tokenization_transfo_xl import TransfoXLCorpus, TransfoXLTokenizer

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_transfo_xl import (
            TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST,
            AdaptiveEmbedding,
            TransfoXLForSequenceClassification,
            TransfoXLLMHeadModel,
            TransfoXLModel,
            TransfoXLPreTrainedModel,
            load_tf_weights_in_transfo_xl,
        )

    try:
        if not is_tf_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_tf_transfo_xl import (
            TF_TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST,
            TFAdaptiveEmbedding,
            TFTransfoXLForSequenceClassification,
            TFTransfoXLLMHeadModel,
            TFTransfoXLMainLayer,
            TFTransfoXLModel,
            TFTransfoXLPreTrainedModel,
        )

else:
    import sys

    __UpperCamelCase    :						Optional[Any]     =							_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)







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


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

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



class 							_UpperCamelCase (						A						):

   '''simple docstring'''







   a_				:							Optional[int]    = "conditional_detr"
   a_				:							Union[str, Any]    = ["past_key_values"]
   a_				:							str    = {
       "hidden_size": "d_model",
       "num_attention_heads": "encoder_attention_heads",
   }

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






         '''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."""							)
                     __lowerCamelCase     :      Any       						=						CONFIG_MAPPING["""resnet"""](out_features=["""stage4"""]							)
               elif isinstance(_lowerCamelCase       ,  _lowerCamelCase							):
                     __lowerCamelCase     :      str       						=						backbone_config.get("""model_type"""							)
                     __lowerCamelCase     :      Optional[Any]       						=						CONFIG_MAPPING[backbone_model_type]
                     __lowerCamelCase     :      Optional[Any]       						=						config_class.from_dict(_lowerCamelCase							)

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

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






         '''simple docstring'''



         return self.encoder_attention_heads

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






         '''simple docstring'''



         return self.d_model


   def   _snake_case    (  self  : int							):






         '''simple docstring'''



         __lowerCamelCase     :      int       						=						copy.deepcopy(self.__dict__							)
         if self.backbone_config is not None:
               __lowerCamelCase     :      Dict       						=						self.backbone_config.to_dict()
         __lowerCamelCase     :      int       						=						self.__class__.model_type
         return output



class 							_UpperCamelCase (						A						):

   '''simple docstring'''







   a_				:							Dict    = version.parse("1.11"						)

   @property
   def   _snake_case    (  self  : Any							):






         '''simple docstring'''



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

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






         '''simple docstring'''



         return 1E-5


   @property
   def   _snake_case    (  self  : Tuple							):






         '''simple docstring'''



         return 1_2



