






import copy
from typing import Dict, List, Optional

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


lowercase  :							List[str]			  =    {
    '''facebook/mask2former-swin-small-coco-instance''': (
        '''https://huggingface.co/facebook/mask2former-swin-small-coco-instance/blob/main/config.json'''
    )
    # See all Mask2Former models at https://huggingface.co/models?filter=mask2former
}

lowercase  :							Any			  =    logging.get_logger(__name__)




class 		UpperCAmelCase_						(	SCREAMING_SNAKE_CASE__					):


						'''simple docstring'''




						A     :   Optional[int]						=					'mask2former'
						A     :   List[Any]						=					['swin']
						A     :   Dict						=					{'hidden_size': 'hidden_dim'}






						def __init__(	self		,				_SCREAMING_SNAKE_CASE = None		,				_SCREAMING_SNAKE_CASE = 256		,				_SCREAMING_SNAKE_CASE = 256		,				_SCREAMING_SNAKE_CASE = 256		,				_SCREAMING_SNAKE_CASE = 1024		,				_SCREAMING_SNAKE_CASE = "relu"		,				_SCREAMING_SNAKE_CASE = 6		,				_SCREAMING_SNAKE_CASE = 10		,				_SCREAMING_SNAKE_CASE = 8		,				_SCREAMING_SNAKE_CASE = 0.0		,				_SCREAMING_SNAKE_CASE = 2048		,				_SCREAMING_SNAKE_CASE = False		,				_SCREAMING_SNAKE_CASE = False		,				_SCREAMING_SNAKE_CASE = 4		,				_SCREAMING_SNAKE_CASE = 255		,				_SCREAMING_SNAKE_CASE = 100		,				_SCREAMING_SNAKE_CASE = 0.1		,				_SCREAMING_SNAKE_CASE = 2.0		,				_SCREAMING_SNAKE_CASE = 5.0		,				_SCREAMING_SNAKE_CASE = 5.0		,				_SCREAMING_SNAKE_CASE = 1_2544		,				_SCREAMING_SNAKE_CASE = 3.0		,				_SCREAMING_SNAKE_CASE = 0.75		,				_SCREAMING_SNAKE_CASE = 0.02		,				_SCREAMING_SNAKE_CASE = 1.0		,				_SCREAMING_SNAKE_CASE = True		,				_SCREAMING_SNAKE_CASE = [4, 8, 16, 32]		,				_SCREAMING_SNAKE_CASE = None		,				**_SCREAMING_SNAKE_CASE		,				) ->				Union[str, Any]:
								if backbone_config is None:
										logger.info("`backbone_config` is `None`. Initializing the config with the default `Swin` backbone."				)
										snake_case_				:							Dict						 =       CONFIG_MAPPING["swin"](
										    image_size=224		,				in_channels=3		,				patch_size=4		,				embed_dim=96		,				depths=[2, 2, 18, 2]		,				num_heads=[3, 6, 12, 24]		,				window_size=7		,				drop_path_rate=0.3		,				use_absolute_embeddings=_SCREAMING_SNAKE_CASE		,				out_features=["stage1", "stage2", "stage3", "stage4"]		,				)

								if isinstance(_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE				):
										snake_case_				:							Any						 =       backbone_config.pop("model_type"				)
										snake_case_				:							Dict						 =       CONFIG_MAPPING[backbone_model_type]
										snake_case_				:							Any						 =       config_class.from_dict(_SCREAMING_SNAKE_CASE				)

								# 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 Mask2Former. '''
										    f'''Supported model types: {','.join(self.backbones_supported				)}'''				)

								snake_case_				:							Union[str, Any]						 =       backbone_config
								snake_case_				:							Optional[Any]						 =       feature_size
								snake_case_				:							Dict						 =       mask_feature_size
								snake_case_				:							str						 =       hidden_dim
								snake_case_				:							str						 =       encoder_feedforward_dim
								snake_case_				:							Dict						 =       activation_function
								snake_case_				:							Any						 =       encoder_layers
								snake_case_				:							str						 =       decoder_layers
								snake_case_				:							Tuple						 =       num_attention_heads
								snake_case_				:							Union[str, Any]						 =       dropout
								snake_case_				:							Optional[int]						 =       dim_feedforward
								snake_case_				:							List[str]						 =       pre_norm
								snake_case_				:							Tuple						 =       enforce_input_projection
								snake_case_				:							Optional[int]						 =       common_stride
								snake_case_				:							List[Any]						 =       ignore_value
								snake_case_				:							List[Any]						 =       num_queries
								snake_case_				:							List[str]						 =       no_object_weight
								snake_case_				:							Union[str, Any]						 =       class_weight
								snake_case_				:							Optional[Any]						 =       mask_weight
								snake_case_				:							Any						 =       dice_weight
								snake_case_				:							Dict						 =       train_num_points
								snake_case_				:							str						 =       oversample_ratio
								snake_case_				:							Any						 =       importance_sample_ratio
								snake_case_				:							Any						 =       init_std
								snake_case_				:							Optional[Any]						 =       init_xavier_std
								snake_case_				:							Tuple						 =       use_auxiliary_loss
								snake_case_				:							str						 =       feature_strides
								snake_case_				:							Any						 =       output_auxiliary_logits
								snake_case_				:							Optional[Any]						 =       decoder_layers

								super().__init__(**_SCREAMING_SNAKE_CASE				)






						@classmethod
						def       _lowerCAmelCase       (	cls		,				_SCREAMING_SNAKE_CASE		,				**_SCREAMING_SNAKE_CASE				) ->				List[Any]:
								return cls(
								    backbone_config=_SCREAMING_SNAKE_CASE		,				**_SCREAMING_SNAKE_CASE		,				)






						def       _lowerCAmelCase       (	self				) ->				Dict[str, any]:
								snake_case_				:							Tuple						 =       copy.deepcopy(self.__dict__				)
								snake_case_				:							Any						 =       self.backbone_config.to_dict()
								snake_case_				:							str						 =       self.__class__.model_type
								return output








from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available


lowercase  :							int			  =    {
    '''configuration_audio_spectrogram_transformer''': [
        '''AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''ASTConfig''',
    ]
}

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							lowercase  :							Optional[Any]			  =    [
							    '''AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST''',
							    '''ASTForAudioClassification''',
							    '''ASTModel''',
							    '''ASTPreTrainedModel''',
							]

try:
							if not is_speech_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							lowercase  :							Optional[int]			  =    ['''ASTFeatureExtractor''']

if TYPE_CHECKING:
							from .configuration_audio_spectrogram_transformer import (
							    AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
							    ASTConfig,
							)

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_audio_spectrogram_transformer import (
														    AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
														    ASTForAudioClassification,
														    ASTModel,
														    ASTPreTrainedModel,
														)

							try:
														if not is_speech_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .feature_extraction_audio_spectrogram_transformer import ASTFeatureExtractor


else:
							import sys

							lowercase  :							Optional[int]			  =    _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)
