


'''simple docstring'''






import copy

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


__UpperCAmelCase       							=				logging.get_logger(__name__)




class 						a__							(				a__    ):





							'''simple docstring'''






							lowercase__     :  Any      		= "upernet"







							def __init__(						self   ,       lowerCamelCase_=None   ,       lowerCamelCase_=5_12   ,       lowerCamelCase_=0.02   ,       lowerCamelCase_=[1, 2, 3, 6]   ,       lowerCamelCase_=True   ,       lowerCamelCase_=0.4   ,       lowerCamelCase_=3_84   ,       lowerCamelCase_=2_56   ,       lowerCamelCase_=1   ,       lowerCamelCase_=False   ,       lowerCamelCase_=2_55   ,       **lowerCamelCase_   ,       )			->				Union[str, Any]:
														super().__init__(**lowerCamelCase_  )

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

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







							def     __SCREAMING_SNAKE_CASE				(						self  )			->				List[Any]:
														lowerCAmelCase__			  =      copy.deepcopy(self.__dict__  )
														lowerCAmelCase__			  =      self.backbone_config.to_dict()
														lowerCAmelCase__			  =      self.__class__.model_type
														return output



'''simple docstring'''






# Copyright 2021 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse

from ...utils.dataclasses import (
    ComputeEnvironment,
    DistributedType,
    DynamoBackend,
    PrecisionType,
    SageMakerDistributedType,
)
from ..menu import BulletMenu


__UpperCAmelCase       							=				[
    '''EAGER''',
    '''AOT_EAGER''',
    '''INDUCTOR''',
    '''NVFUSER''',
    '''AOT_NVFUSER''',
    '''AOT_CUDAGRAPHS''',
    '''OFI''',
    '''FX2TRT''',
    '''ONNXRT''',
    '''IPEX''',
]


def    _snake_case  (	A					,       A=None					,       A=None					,       A=None			)		->       Union[str, Any]:
							lowerCAmelCase__			  =      True
							while ask_again:
														lowerCAmelCase__			  =      input(A			)
														try:
																					if default is not None and len(A			) == 0:
																												return default
																					return convert_value(A			) if convert_value is not None else result
														except Exception:
																					if error_message is not None:
																												print(A			)


def    _snake_case  (	A					,       A=[]					,       A=None					,       A=0			)		->       List[Any]:
							lowerCAmelCase__			  =      BulletMenu(A					,       A			)
							lowerCAmelCase__			  =      menu.run(default_choice=A			)
							return convert_value(A			) if convert_value is not None else result


def    _snake_case  (	A			)		->       Tuple:
							lowerCAmelCase__			  =      int(A			)
							return ComputeEnvironment(['''LOCAL_MACHINE''', '''AMAZON_SAGEMAKER'''][value]			)


def    _snake_case  (	A			)		->       Union[str, Any]:
							lowerCAmelCase__			  =      int(A			)
							return DistributedType(['''NO''', '''MULTI_CPU''', '''MULTI_XPU''', '''MULTI_GPU''', '''MULTI_NPU''', '''TPU'''][value]			)


def    _snake_case  (	A			)		->       str:
							lowerCAmelCase__			  =      int(A			)
							return DynamoBackend(DYNAMO_BACKENDS[value]			).value


def    _snake_case  (	A			)		->       Tuple:
							lowerCAmelCase__			  =      int(A			)
							return PrecisionType(['''no''', '''fp16''', '''bf16''', '''fp8'''][value]			)


def    _snake_case  (	A			)		->       Union[str, Any]:
							lowerCAmelCase__			  =      int(A			)
							return SageMakerDistributedType(['''NO''', '''DATA_PARALLEL''', '''MODEL_PARALLEL'''][value]			)


def    _snake_case  (	A			)		->       List[str]:
							return {"yes": True, "no": False}[value.lower()]






class 						a__							(				argparse.RawDescriptionHelpFormatter    ):





							'''simple docstring'''






							def     __SCREAMING_SNAKE_CASE				(						self   ,       lowerCamelCase_   ,       lowerCamelCase_   ,       lowerCamelCase_   ,       lowerCamelCase_  )			->				Dict:
														lowerCAmelCase__			  =      super()._format_usage(lowerCamelCase_   ,       lowerCamelCase_   ,       lowerCamelCase_   ,       lowerCamelCase_  )
														lowerCAmelCase__			  =      usage.replace('''<command> [<args>] '''   ,       ''''''  )
														return usage