





from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


SCREAMING_SNAKE_CASE_						   =       logging.get_logger(__name__)

SCREAMING_SNAKE_CASE_						   =       {
    """shi-labs/nat-mini-in1k-224""": """https://huggingface.co/shi-labs/nat-mini-in1k-224/resolve/main/config.json""",
    # See all Nat models at https://huggingface.co/models?filter=nat
}

class 		UpperCamelCase__ (      lowerCAmelCase_							,      lowerCAmelCase_   ):



     '''simple docstring'''

     __snake_case    :	Optional[int]			=			"nat"

     __snake_case    :	Dict			=			{
         "num_attention_heads": "num_heads",
         "num_hidden_layers": "num_layers",
     }






     def __init__(							self						:    str						,lowerCamelCase__						:    Dict=4						,lowerCamelCase__						:    List[str]=3						,lowerCamelCase__						:    Optional[Any]=64						,lowerCamelCase__						:    Tuple=[3, 4, 6, 5]						,lowerCamelCase__						:    Union[str, Any]=[2, 4, 8, 16]						,lowerCamelCase__						:    List[str]=7						,lowerCamelCase__						:    Optional[int]=3.0						,lowerCamelCase__						:    Union[str, Any]=True						,lowerCamelCase__						:    Any=0.0						,lowerCamelCase__						:    Any=0.0						,lowerCamelCase__						:    str=0.1						,lowerCamelCase__						:    Optional[int]="gelu"						,lowerCamelCase__						:    List[Any]=0.02						,lowerCamelCase__						:    int=1e-5						,lowerCamelCase__						:    str=0.0						,lowerCamelCase__						:    List[Any]=None						,lowerCamelCase__						:    Union[str, Any]=None						,**lowerCamelCase__						:    Optional[Any]						,)     ->		Any:




           '''simple docstring'''


           super().__init__(**lowerCamelCase__       )

           SCREAMING_SNAKE_CASE		=						patch_size
           SCREAMING_SNAKE_CASE		=						num_channels
           SCREAMING_SNAKE_CASE		=						embed_dim
           SCREAMING_SNAKE_CASE		=						depths
           SCREAMING_SNAKE_CASE		=						len(lowerCamelCase__       )
           SCREAMING_SNAKE_CASE		=						num_heads
           SCREAMING_SNAKE_CASE		=						kernel_size
           SCREAMING_SNAKE_CASE		=						mlp_ratio
           SCREAMING_SNAKE_CASE		=						qkv_bias
           SCREAMING_SNAKE_CASE		=						hidden_dropout_prob
           SCREAMING_SNAKE_CASE		=						attention_probs_dropout_prob
           SCREAMING_SNAKE_CASE		=						drop_path_rate
           SCREAMING_SNAKE_CASE		=						hidden_act
           SCREAMING_SNAKE_CASE		=						layer_norm_eps
           SCREAMING_SNAKE_CASE		=						initializer_range
           # we set the hidden_size attribute in order to make Nat work with VisionEncoderDecoderModel
           # this indicates the channel dimension after the last stage of the model
           SCREAMING_SNAKE_CASE		=						int(embed_dim * 2 ** (len(lowerCamelCase__       ) - 1)       )
           SCREAMING_SNAKE_CASE		=						layer_scale_init_value
           SCREAMING_SNAKE_CASE		=						["""stem"""] + [F"""stage{idx}""" for idx in range(1						,len(lowerCamelCase__       ) + 1       )]
           SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE		=						get_aligned_output_features_output_indices(
               out_features=lowerCamelCase__						,out_indices=lowerCamelCase__						,stage_names=self.stage_names       )









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

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

class 		UpperCamelCase__ (      lowerCAmelCase_   ):



     '''simple docstring'''

     __snake_case    :	Union[str, Any]			=			"table-transformer"
     __snake_case    :	Union[str, Any]			=			["past_key_values"]
     __snake_case    :	List[Any]			=			{
         "hidden_size": "d_model",
         "num_attention_heads": "encoder_attention_heads",
     }






     def __init__(							self						:    Optional[int]						,lowerCamelCase__						:    Optional[Any]=True						,lowerCamelCase__						:    Optional[Any]=None						,lowerCamelCase__						:    List[Any]=3						,lowerCamelCase__						:    Optional[int]=100						,lowerCamelCase__						:    List[Any]=6						,lowerCamelCase__						:    Dict=2048						,lowerCamelCase__						:    List[Any]=8						,lowerCamelCase__						:    Dict=6						,lowerCamelCase__						:    Dict=2048						,lowerCamelCase__						:    Any=8						,lowerCamelCase__						:    Optional[int]=0.0						,lowerCamelCase__						:    int=0.0						,lowerCamelCase__						:    List[Any]=True						,lowerCamelCase__						:    Optional[int]="relu"						,lowerCamelCase__						:    Tuple=256						,lowerCamelCase__						:    Any=0.1						,lowerCamelCase__						:    Optional[Any]=0.0						,lowerCamelCase__						:    Tuple=0.0						,lowerCamelCase__						:    List[Any]=0.02						,lowerCamelCase__						:    int=1.0						,lowerCamelCase__						:    List[str]=False						,lowerCamelCase__						:    Optional[Any]="sine"						,lowerCamelCase__						:    List[str]="resnet50"						,lowerCamelCase__						:    Optional[Any]=True						,lowerCamelCase__						:    List[str]=False						,lowerCamelCase__						:    int=1						,lowerCamelCase__						:    Dict=5						,lowerCamelCase__						:    Tuple=2						,lowerCamelCase__						:    Union[str, Any]=1						,lowerCamelCase__						:    str=1						,lowerCamelCase__						:    Any=5						,lowerCamelCase__						:    Tuple=2						,lowerCamelCase__						:    str=0.1						,**lowerCamelCase__						:    List[str]						,)     ->		Optional[int]:




           '''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."""       )
                       SCREAMING_SNAKE_CASE		=						CONFIG_MAPPING["""resnet"""](out_features=["""stage4"""]       )
                 elif isinstance(lowerCamelCase__						,lowerCamelCase__       ):
                       SCREAMING_SNAKE_CASE		=						backbone_config.get("""model_type"""       )
                       SCREAMING_SNAKE_CASE		=						CONFIG_MAPPING[backbone_model_type]
                       SCREAMING_SNAKE_CASE		=						config_class.from_dict(lowerCamelCase__       )
                 # set timm attributes to None
                 SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE,					SCREAMING_SNAKE_CASE		=						None, None, None

           SCREAMING_SNAKE_CASE		=						use_timm_backbone
           SCREAMING_SNAKE_CASE		=						backbone_config
           SCREAMING_SNAKE_CASE		=						num_channels
           SCREAMING_SNAKE_CASE		=						num_queries
           SCREAMING_SNAKE_CASE		=						d_model
           SCREAMING_SNAKE_CASE		=						encoder_ffn_dim
           SCREAMING_SNAKE_CASE		=						encoder_layers
           SCREAMING_SNAKE_CASE		=						encoder_attention_heads
           SCREAMING_SNAKE_CASE		=						decoder_ffn_dim
           SCREAMING_SNAKE_CASE		=						decoder_layers
           SCREAMING_SNAKE_CASE		=						decoder_attention_heads
           SCREAMING_SNAKE_CASE		=						dropout
           SCREAMING_SNAKE_CASE		=						attention_dropout
           SCREAMING_SNAKE_CASE		=						activation_dropout
           SCREAMING_SNAKE_CASE		=						activation_function
           SCREAMING_SNAKE_CASE		=						init_std
           SCREAMING_SNAKE_CASE		=						init_xavier_std
           SCREAMING_SNAKE_CASE		=						encoder_layerdrop
           SCREAMING_SNAKE_CASE		=						decoder_layerdrop
           SCREAMING_SNAKE_CASE		=						encoder_layers
           SCREAMING_SNAKE_CASE		=						auxiliary_loss
           SCREAMING_SNAKE_CASE		=						position_embedding_type
           SCREAMING_SNAKE_CASE		=						backbone
           SCREAMING_SNAKE_CASE		=						use_pretrained_backbone
           SCREAMING_SNAKE_CASE		=						dilation
           # Hungarian matcher
           SCREAMING_SNAKE_CASE		=						class_cost
           SCREAMING_SNAKE_CASE		=						bbox_cost
           SCREAMING_SNAKE_CASE		=						giou_cost
           # Loss coefficients
           SCREAMING_SNAKE_CASE		=						mask_loss_coefficient
           SCREAMING_SNAKE_CASE		=						dice_loss_coefficient
           SCREAMING_SNAKE_CASE		=						bbox_loss_coefficient
           SCREAMING_SNAKE_CASE		=						giou_loss_coefficient
           SCREAMING_SNAKE_CASE		=						eos_coefficient
           super().__init__(is_encoder_decoder=lowerCamelCase__						,**lowerCamelCase__       )






     @property
     def 				SCREAMING_SNAKE_CASE__  (							self						:    Union[str, Any]       )     ->		int:




           '''simple docstring'''


           return self.encoder_attention_heads






     @property
     def 				SCREAMING_SNAKE_CASE__  (							self						:    Optional[Any]       )     ->		int:




           '''simple docstring'''


           return self.d_model

class 		UpperCamelCase__ (      lowerCAmelCase_   ):



     '''simple docstring'''

     __snake_case    :	int			=			version.parse("1.11"   )






     @property
     def 				SCREAMING_SNAKE_CASE__  (							self						:    Union[str, 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 				SCREAMING_SNAKE_CASE__  (							self						:    Optional[int]       )     ->		float:




           '''simple docstring'''


           return 1e-5






     @property
     def 				SCREAMING_SNAKE_CASE__  (							self						:    Any       )     ->		int:




           '''simple docstring'''


           return 12


