





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	:	int		     =       logging.get_logger(__name__)

UpperCAmelCase	:	List[str]		     =       {
    """microsoft/conditional-detr-resnet-50""": (
        """https://huggingface.co/microsoft/conditional-detr-resnet-50/resolve/main/config.json"""
    ),
}







class 				__lowerCAmelCase       (    UpperCamelCase__):
      _lowercase				:					int						=			"""conditional_detr"""
      _lowercase				:					int						=			["""past_key_values"""]
      _lowercase				:					str						=			{
          """hidden_size""": """d_model""",
          """num_attention_heads""": """encoder_attention_heads""",
      }







      def __init__(    self		,      lowerCAmelCase__=True		,      lowerCAmelCase__=None		,      lowerCAmelCase__=3		,      lowerCAmelCase__=3_0_0		,      lowerCAmelCase__=6		,      lowerCAmelCase__=2_0_4_8		,      lowerCAmelCase__=8		,      lowerCAmelCase__=6		,      lowerCAmelCase__=2_0_4_8		,      lowerCAmelCase__=8		,      lowerCAmelCase__=0.0		,      lowerCAmelCase__=0.0		,      lowerCAmelCase__=True		,      lowerCAmelCase__="relu"		,      lowerCAmelCase__=2_5_6		,      lowerCAmelCase__=0.1		,      lowerCAmelCase__=0.0		,      lowerCAmelCase__=0.0		,      lowerCAmelCase__=0.02		,      lowerCAmelCase__=1.0		,      lowerCAmelCase__=False		,      lowerCAmelCase__="sine"		,      lowerCAmelCase__="resnet50"		,      lowerCAmelCase__=True		,      lowerCAmelCase__=False		,      lowerCAmelCase__=2		,      lowerCAmelCase__=5		,      lowerCAmelCase__=2		,      lowerCAmelCase__=1		,      lowerCAmelCase__=1		,      lowerCAmelCase__=2		,      lowerCAmelCase__=5		,      lowerCAmelCase__=2		,      lowerCAmelCase__=0.25		,      **lowerCAmelCase__		,      )   ->						List[str]:



        '''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__	:					int										=CONFIG_MAPPING["resnet"](out_features=["stage4"]							)
          elif isinstance(lowerCAmelCase__		,      lowerCAmelCase__							):
            a__	:					Tuple										=backbone_config.get("model_type"							)
            a__	:					Dict										=CONFIG_MAPPING[backbone_model_type]
            a__	:					str										=config_class.from_dict(lowerCAmelCase__							)

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







      @property
      def    _lowercase  (    self							)   ->						int:



        '''simple docstring'''




        return self.encoder_attention_heads







      @property
      def    _lowercase  (    self							)   ->						int:



        '''simple docstring'''




        return self.d_model







      def    _lowercase  (    self							)   ->						Union[str, Any]:



        '''simple docstring'''




        a__	:					Optional[int]										=copy.deepcopy(self.__dict__							)
        if self.backbone_config is not None:
          a__	:					Tuple										=self.backbone_config.to_dict()
        a__	:					List[Any]										=self.__class__.model_type
        return output







class 				__lowerCAmelCase       (    UpperCamelCase__):
      _lowercase				:					Any						=			version.parse("""1.11""")







      @property
      def    _lowercase  (    self							)   ->						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    _lowercase  (    self							)   ->						float:



        '''simple docstring'''




        return 1E-5







      @property
      def    _lowercase  (    self							)   ->						int:



        '''simple docstring'''




        return 1_2













from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


UpperCAmelCase	:	Any		     =       {
    """configuration_convbert""": ["""CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ConvBertConfig""", """ConvBertOnnxConfig"""],
    """tokenization_convbert""": ["""ConvBertTokenizer"""],
}

try:
     if not is_tokenizers_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     UpperCAmelCase	:	List[Any]		     =       ["""ConvBertTokenizerFast"""]

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     UpperCAmelCase	:	List[str]		     =       [
         """CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
         """ConvBertForMaskedLM""",
         """ConvBertForMultipleChoice""",
         """ConvBertForQuestionAnswering""",
         """ConvBertForSequenceClassification""",
         """ConvBertForTokenClassification""",
         """ConvBertLayer""",
         """ConvBertModel""",
         """ConvBertPreTrainedModel""",
         """load_tf_weights_in_convbert""",
     ]


try:
     if not is_tf_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     UpperCAmelCase	:	Union[str, Any]		     =       [
         """TF_CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
         """TFConvBertForMaskedLM""",
         """TFConvBertForMultipleChoice""",
         """TFConvBertForQuestionAnswering""",
         """TFConvBertForSequenceClassification""",
         """TFConvBertForTokenClassification""",
         """TFConvBertLayer""",
         """TFConvBertModel""",
         """TFConvBertPreTrainedModel""",
     ]


if TYPE_CHECKING:
     from .configuration_convbert import CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, ConvBertConfig, ConvBertOnnxConfig
     from .tokenization_convbert import ConvBertTokenizer

     try:
          if not is_tokenizers_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_convbert_fast import ConvBertTokenizerFast

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_convbert import (
              CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
              ConvBertForMaskedLM,
              ConvBertForMultipleChoice,
              ConvBertForQuestionAnswering,
              ConvBertForSequenceClassification,
              ConvBertForTokenClassification,
              ConvBertLayer,
              ConvBertModel,
              ConvBertPreTrainedModel,
              load_tf_weights_in_convbert,
          )

     try:
          if not is_tf_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_tf_convbert import (
              TF_CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
              TFConvBertForMaskedLM,
              TFConvBertForMultipleChoice,
              TFConvBertForQuestionAnswering,
              TFConvBertForSequenceClassification,
              TFConvBertForTokenClassification,
              TFConvBertLayer,
              TFConvBertModel,
              TFConvBertPreTrainedModel,
          )


else:
     import sys

     UpperCAmelCase	:	Union[str, Any]		     =       _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)






