






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 ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


UpperCamelCase__     =	logging.get_logger(__name__)

UpperCamelCase__     =	{
    "microsoft/resnet-50": "https://huggingface.co/microsoft/resnet-50/blob/main/config.json",
}

class     __SCREAMING_SNAKE_CASE   (       _a				,						_a    ):
							snake_case       : Any         =    '''resnet'''
							snake_case       : List[Any]         =    ['''basic''', '''bottleneck''']






							def __init__(  self					,	__lowerCAmelCase=3					,	__lowerCAmelCase=64					,	__lowerCAmelCase=[256, 512, 1024, 2048]					,	__lowerCAmelCase=[3, 4, 6, 3]					,	__lowerCAmelCase="bottleneck"					,	__lowerCAmelCase="relu"					,	__lowerCAmelCase=False					,	__lowerCAmelCase=None					,	__lowerCAmelCase=None					,	**__lowerCAmelCase					,	):
														super().__init__(**_snake_case					)
														if layer_type not in self.layer_types:
																					raise ValueError(f"""layer_type={layer_type} is not one of {",".join(self.layer_types					)}"""					)
														UpperCamelCase__			       =     num_channels
														UpperCamelCase__			       =     embedding_size
														UpperCamelCase__			       =     hidden_sizes
														UpperCamelCase__			       =     depths
														UpperCamelCase__			       =     layer_type
														UpperCamelCase__			       =     hidden_act
														UpperCamelCase__			       =     downsample_in_first_stage
														UpperCamelCase__			       =     ["""stem"""] + [f"""stage{idx}""" for idx in range(1					,	len(_snake_case					) + 1					)]
														UpperCamelCase__       ,       UpperCamelCase__			       =     get_aligned_output_features_output_indices(
														    out_features=_snake_case					,	out_indices=_snake_case					,	stage_names=self.stage_names					)






class     __SCREAMING_SNAKE_CASE   (       _a    ):
							snake_case       : str         =    version.parse("""1.11"""    )






							@property
							def 			_lowerCamelCase						(  self					):
														return OrderedDict(
														    [
														        ("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""}),
														    ]					)







							@property
							def 			_lowerCamelCase						(  self					):
														return 1E-3











import copy

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


UpperCamelCase__     =	logging.get_logger(__name__)

class     __SCREAMING_SNAKE_CASE   (       _a    ):
							snake_case       : List[Any]         =    """upernet"""






							def __init__(  self					,	__lowerCAmelCase=None					,	__lowerCAmelCase=512					,	__lowerCAmelCase=0.02					,	__lowerCAmelCase=[1, 2, 3, 6]					,	__lowerCAmelCase=True					,	__lowerCAmelCase=0.4					,	__lowerCAmelCase=384					,	__lowerCAmelCase=256					,	__lowerCAmelCase=1					,	__lowerCAmelCase=False					,	__lowerCAmelCase=255					,	**__lowerCAmelCase					,	):
														super().__init__(**__lowerCAmelCase					)

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

														UpperCamelCase__			       =     backbone_config
														UpperCamelCase__			       =     hidden_size
														UpperCamelCase__			       =     initializer_range
														UpperCamelCase__			       =     pool_scales
														UpperCamelCase__			       =     use_auxiliary_head
														UpperCamelCase__			       =     auxiliary_loss_weight
														UpperCamelCase__			       =     auxiliary_in_channels
														UpperCamelCase__			       =     auxiliary_channels
														UpperCamelCase__			       =     auxiliary_num_convs
														UpperCamelCase__			       =     auxiliary_concat_input
														UpperCamelCase__			       =     loss_ignore_index







							def 			_lowerCamelCase						(  self					):
														UpperCamelCase__			       =     copy.deepcopy(self.__dict__					)
														UpperCamelCase__			       =     self.backbone_config.to_dict()
														UpperCamelCase__			       =     self.__class__.model_type
														return output




