






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__       :			Dict			      =						{
    """microsoft/table-transformer-detection""": (
        """https://huggingface.co/microsoft/table-transformer-detection/resolve/main/config.json"""
    ),
}







class   __lowerCAmelCase			(					_snake_case  ):
   _UpperCamelCase :						str     		=				"""table-transformer"""
   _UpperCamelCase :						Optional[Any]     		=				["""past_key_values"""]
   _UpperCamelCase :						Dict     		=				{
       """hidden_size""": """d_model""",
       """num_attention_heads""": """encoder_attention_heads""",
   }





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

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





   @property
   def 	_snake_case ( self      )				->  Dict:
      """simple docstring"""





      return self.encoder_attention_heads





   @property
   def 	_snake_case ( self      )				->  List[str]:
      """simple docstring"""





      return self.d_model







class   __lowerCAmelCase			(					_snake_case  ):
   _UpperCamelCase :						List[str]     		=				version.parse("""1.11"""  )





   @property
   def 	_snake_case ( self      )				->  List[str]:
      """simple docstring"""





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





   @property
   def 	_snake_case ( self      )				->  List[str]:
      """simple docstring"""





      return 1E-5





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





      return 12








import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import CONFIG_MAPPING


SCREAMING_SNAKE_CASE__       :			int			      =						logging.get_logger(__name__)







class   __lowerCAmelCase			(					_UpperCamelCase  ):
   _UpperCamelCase :						int     		=				"""upernet"""





   def __init__( self					,			snake_case=None					,			snake_case=512					,			snake_case=0.02					,			snake_case=[1, 2, 3, 6]					,			snake_case=True					,			snake_case=0.4					,			snake_case=384					,			snake_case=256					,			snake_case=1					,			snake_case=False					,			snake_case=255					,			**snake_case					,			)				->  Optional[Any]:
      """simple docstring"""





      super().__init__(**snake_case      )

      if backbone_config is None:
         logger.info("`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone."      )
         a__	:						List[str]      		=  CONFIG_MAPPING["resnet"](out_features=["stage1", "stage2", "stage3", "stage4"]      )
      elif isinstance(snake_case					,			snake_case      ):
         a__	:						Optional[int]      		=  backbone_config.get("model_type"      )
         a__	:						str      		=  CONFIG_MAPPING[backbone_model_type]
         a__	:						str      		=  config_class.from_dict(snake_case      )

      a__	:						int      		=  backbone_config
      a__	:						Optional[Any]      		=  hidden_size
      a__	:						Optional[Any]      		=  initializer_range
      a__	:						Tuple      		=  pool_scales
      a__	:						Optional[Any]      		=  use_auxiliary_head
      a__	:						Optional[Any]      		=  auxiliary_loss_weight
      a__	:						Dict      		=  auxiliary_in_channels
      a__	:						Optional[int]      		=  auxiliary_channels
      a__	:						Any      		=  auxiliary_num_convs
      a__	:						Any      		=  auxiliary_concat_input
      a__	:						int      		=  loss_ignore_index





   def 	_snake_case ( self      )				->  str:
      """simple docstring"""





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

