
'''simple docstring'''







import copy

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


_lowercase :  Any    							=       logging.get_logger(__name__)






class  lowerCAmelCase__   (  lowerCamelCase_     ):
					lowerCAmelCase_        =     '''upernet'''






					def __init__(   self				,							__SCREAMING_SNAKE_CASE=None				,							__SCREAMING_SNAKE_CASE=5_12				,							__SCREAMING_SNAKE_CASE=0.02				,							__SCREAMING_SNAKE_CASE=[1, 2, 3, 6]				,							__SCREAMING_SNAKE_CASE=True				,							__SCREAMING_SNAKE_CASE=0.4				,							__SCREAMING_SNAKE_CASE=3_84				,							__SCREAMING_SNAKE_CASE=2_56				,							__SCREAMING_SNAKE_CASE=1				,							__SCREAMING_SNAKE_CASE=False				,							__SCREAMING_SNAKE_CASE=2_55				,							**__SCREAMING_SNAKE_CASE				,							):


											"""simple docstring"""





											super().__init__(**__SCREAMING_SNAKE_CASE		)

											if backbone_config is None:
																	logger.info('''`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone.'''		)
																	lowercase_	:     List[str]													=       CONFIG_MAPPING['''resnet'''](out_features=['''stage1''', '''stage2''', '''stage3''', '''stage4''']		)
											elif isinstance(__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		):
																	lowercase_	:     Tuple													=       backbone_config.get('''model_type'''		)
																	lowercase_	:     Dict													=       CONFIG_MAPPING[backbone_model_type]
																	lowercase_	:     Tuple													=       config_class.from_dict(__SCREAMING_SNAKE_CASE		)

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






					def 	_snake_case    (   self		):


											"""simple docstring"""





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





'''simple docstring'''







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


_lowercase :  int    							=       logging.get_logger(__name__)

_lowercase :  List[Any]    							=       {
    "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  lowerCAmelCase__   (  lowerCamelCase_    ,						lowerCamelCase_     ):
					lowerCAmelCase_        =     '''nat'''

					lowerCAmelCase_        =     {
					    '''num_attention_heads''': '''num_heads''',
					    '''num_hidden_layers''': '''num_layers''',
					}






					def __init__(   self				,							__SCREAMING_SNAKE_CASE=4				,							__SCREAMING_SNAKE_CASE=3				,							__SCREAMING_SNAKE_CASE=64				,							__SCREAMING_SNAKE_CASE=[3, 4, 6, 5]				,							__SCREAMING_SNAKE_CASE=[2, 4, 8, 16]				,							__SCREAMING_SNAKE_CASE=7				,							__SCREAMING_SNAKE_CASE=3.0				,							__SCREAMING_SNAKE_CASE=True				,							__SCREAMING_SNAKE_CASE=0.0				,							__SCREAMING_SNAKE_CASE=0.0				,							__SCREAMING_SNAKE_CASE=0.1				,							__SCREAMING_SNAKE_CASE="gelu"				,							__SCREAMING_SNAKE_CASE=0.02				,							__SCREAMING_SNAKE_CASE=1E-5				,							__SCREAMING_SNAKE_CASE=0.0				,							__SCREAMING_SNAKE_CASE=None				,							__SCREAMING_SNAKE_CASE=None				,							**__SCREAMING_SNAKE_CASE				,							):


											"""simple docstring"""





											super().__init__(**__SCREAMING_SNAKE_CASE		)

											lowercase_	:     Optional[int]													=       patch_size
											lowercase_	:     List[Any]													=       num_channels
											lowercase_	:     str													=       embed_dim
											lowercase_	:     List[str]													=       depths
											lowercase_	:     str													=       len(__SCREAMING_SNAKE_CASE		)
											lowercase_	:     Tuple													=       num_heads
											lowercase_	:     int													=       kernel_size
											lowercase_	:     Union[str, Any]													=       mlp_ratio
											lowercase_	:     Optional[int]													=       qkv_bias
											lowercase_	:     List[Any]													=       hidden_dropout_prob
											lowercase_	:     Optional[int]													=       attention_probs_dropout_prob
											lowercase_	:     List[Any]													=       drop_path_rate
											lowercase_	:     List[Any]													=       hidden_act
											lowercase_	:     int													=       layer_norm_eps
											lowercase_	:     int													=       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
											lowercase_	:     Dict													=       int(embed_dim * 2 ** (len(__SCREAMING_SNAKE_CASE		) - 1)		)
											lowercase_	:     Tuple													=       layer_scale_init_value
											lowercase_	:     Union[str, Any]													=       ['''stem'''] + [F'''stage{idx}''' for idx in range(1				,							len(__SCREAMING_SNAKE_CASE		) + 1		)]
											lowercase_						, lowercase_	:     int													=       get_aligned_output_features_output_indices(
											    out_features=__SCREAMING_SNAKE_CASE				,							out_indices=__SCREAMING_SNAKE_CASE				,							stage_names=self.stage_names		)



