






"""simple docstring"""






import copy
from typing import Dict, Optional

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto import CONFIG_MAPPING
from ..detr import DetrConfig
from ..swin import SwinConfig


SCREAMING_SNAKE_CASE    :    Optional[Any]        =							{
    'facebook/maskformer-swin-base-ade': (
        'https://huggingface.co/facebook/maskformer-swin-base-ade/blob/main/config.json'
    )
    # See all MaskFormer models at https://huggingface.co/models?filter=maskformer
}

SCREAMING_SNAKE_CASE    :    Any        =							logging.get_logger(__name__)





class    snake_case_							(     _lowerCamelCase							):



	"""simple docstring"""

	SCREAMING_SNAKE_CASE_:				Optional[int]       =       '''maskformer'''
	SCREAMING_SNAKE_CASE_:				Optional[int]       =       {'''hidden_size''': '''mask_feature_size'''}
	SCREAMING_SNAKE_CASE_:				int       =       ['''resnet''', '''swin''']
	SCREAMING_SNAKE_CASE_:				str       =       ['''detr''']


	def __init__(   self	,       __a = 256	,       __a = 256	,       __a = 0.1	,       __a = False	,       __a = None	,       __a = None	,       __a = 0.02	,       __a = 1.0	,       __a = 1.0	,       __a = 1.0	,       __a = 20.0	,       __a = None	,       **__a	,       ):


					"""simple docstring"""

					if backbone_config is None:
									# fall back to https://huggingface.co/microsoft/swin-base-patch4-window12-384-in22k
									A__							=							SwinConfig(
									    image_size=384	,       in_channels=3	,       patch_size=4	,       embed_dim=128	,       depths=[2, 2, 18, 2]	,       num_heads=[4, 8, 16, 32]	,       window_size=12	,       drop_path_rate=0.3	,       out_features=['stage1', 'stage2', 'stage3', 'stage4']	,       )

					if isinstance(A__	,       A__    ):
									A__							=							backbone_config.pop('model_type'    )
									A__							=							CONFIG_MAPPING[backbone_model_type]
									A__							=							config_class.from_dict(A__    )

					# verify that the backbone is supported
					if backbone_config.model_type not in self.backbones_supported:
									logger.warning_once(
									    f'''Backbone {backbone_config.model_type} is not a supported model and may not be compatible with MaskFormer. '''
									    f'''Supported model types: {','.join(self.backbones_supported    )}'''    )

					if decoder_config is None:
									# fall back to https://huggingface.co/facebook/detr-resnet-50
									A__							=							DetrConfig()
					else:
									# verify that the decoder is supported
									A__							=							(
									    decoder_config.pop('model_type'    ) if isinstance(A__	,       A__    ) else decoder_config.model_type
									)
									if decoder_type not in self.decoders_supported:
													raise ValueError(
													    f'''Transformer Decoder {decoder_type} not supported, please use one of'''
													    f''' {','.join(self.decoders_supported    )}'''    )
									if isinstance(A__	,       A__    ):
													A__							=							CONFIG_MAPPING[decoder_type]
													A__							=							config_class.from_dict(A__    )

					A__							=							backbone_config
					A__							=							decoder_config
					# main feature dimension for the model
					A__							=							fpn_feature_size
					A__							=							mask_feature_size
					# initializer
					A__							=							init_std
					A__							=							init_xavier_std
					# Hungarian matcher && loss
					A__							=							cross_entropy_weight
					A__							=							dice_weight
					A__							=							mask_weight
					A__							=							use_auxiliary_loss
					A__							=							no_object_weight
					A__							=							output_auxiliary_logits

					A__							=							self.decoder_config.encoder_attention_heads
					A__							=							self.decoder_config.num_hidden_layers
					super().__init__(**A__    )


	@classmethod
	def    _UpperCAmelCase    (   cls	,       __a	,       __a	,       **__a    ):


					"""simple docstring"""

					return cls(
					    backbone_config=A__	,       decoder_config=A__	,       **A__	,       )






	def    _UpperCAmelCase    (   self    ):


					"""simple docstring"""

					A__							=							copy.deepcopy(self.__dict__    )
					A__							=							self.backbone_config.to_dict()
					A__							=							self.decoder_config.to_dict()
					A__							=							self.__class__.model_type
					return output





from ..utils import DummyObject, requires_backends



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[str]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Any    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Union[str, Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Dict    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[str]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Any    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Optional[int]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  str    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Dict    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  int    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  int    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  str    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[str]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Optional[int]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Union[str, Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Tuple    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  str    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Dict    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  str    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Any    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Union[str, Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Optional[Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Tuple    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



