
"""simple docstring"""






import copy
from typing import Dict, List, Optional

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


lowerCamelCase__ :       int						     =			{
    "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
}

lowerCamelCase__ :       Union[str, Any]						     =			logging.get_logger(__name__)




class 				lowercase__(				_UpperCAmelCase   ):
	'''simple docstring'''

	UpperCamelCase				=  """mask2former"""
	UpperCamelCase				=  ["""swin"""]
	UpperCamelCase				=  {"""hidden_size""": """hidden_dim"""}





	def __init__(						self    :Optional[Any]		, lowerCamelCase_    :Optional[Dict] = None		, lowerCamelCase_    :int = 2_56		, lowerCamelCase_    :int = 2_56		, lowerCamelCase_    :int = 2_56		, lowerCamelCase_    :int = 10_24		, lowerCamelCase_    :str = "relu"		, lowerCamelCase_    :int = 6		, lowerCamelCase_    :int = 10		, lowerCamelCase_    :int = 8		, lowerCamelCase_    :float = 0.0		, lowerCamelCase_    :int = 20_48		, lowerCamelCase_    :bool = False		, lowerCamelCase_    :bool = False		, lowerCamelCase_    :int = 4		, lowerCamelCase_    :int = 2_55		, lowerCamelCase_    :int = 1_00		, lowerCamelCase_    :float = 0.1		, lowerCamelCase_    :float = 2.0		, lowerCamelCase_    :float = 5.0		, lowerCamelCase_    :float = 5.0		, lowerCamelCase_    :int = 1_25_44		, lowerCamelCase_    :float = 3.0		, lowerCamelCase_    :float = 0.7_5		, lowerCamelCase_    :float = 0.0_2		, lowerCamelCase_    :float = 1.0		, lowerCamelCase_    :bool = True		, lowerCamelCase_    :List[int] = [4, 8, 16, 32]		, lowerCamelCase_    :bool = None		, **lowerCamelCase_    :int		, )							->			List[str]:







			'''simple docstring'''




			if backbone_config is None:
					logger.info('''`backbone_config` is `None`. Initializing the config with the default `Swin` backbone.'''					)
					SCREAMING_SNAKE_CASE       :     Any				= CONFIG_MAPPING['''swin'''](
					    image_size=2_24		, 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=lowerCamelCase_		, out_features=['''stage1''', '''stage2''', '''stage3''', '''stage4''']		, )

			if isinstance(lowerCamelCase_		, lowerCamelCase_					):
					SCREAMING_SNAKE_CASE       :     Any				= backbone_config.pop('''model_type'''					)
					SCREAMING_SNAKE_CASE       :     str				= CONFIG_MAPPING[backbone_model_type]
					SCREAMING_SNAKE_CASE       :     List[str]				= config_class.from_dict(lowerCamelCase_					)

			# 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					)}"					)

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

			super().__init__(**lowerCamelCase_					)





	@classmethod
	def   __lowerCAmelCase (						cls    :int		, lowerCamelCase_    :PretrainedConfig		, **lowerCamelCase_    :int					)							->			Union[str, Any]:







			'''simple docstring'''




			return cls(
			    backbone_config=lowerCamelCase_		, **lowerCamelCase_		, )







	def   __lowerCAmelCase (						self    :Optional[Any]					)							->			Dict[str, any]:







			'''simple docstring'''




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







"""simple docstring"""






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


lowerCamelCase__ :       Optional[Any]						     =			{
    "configuration_funnel": ["FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP", "FunnelConfig"],
    "convert_funnel_original_tf_checkpoint_to_pytorch": [],
    "tokenization_funnel": ["FunnelTokenizer"],
}

try:
					if not is_tokenizers_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowerCamelCase__ :       Optional[Any]						     =			["FunnelTokenizerFast"]

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowerCamelCase__ :       Dict						     =			[
					    "FUNNEL_PRETRAINED_MODEL_ARCHIVE_LIST",
					    "FunnelBaseModel",
					    "FunnelForMaskedLM",
					    "FunnelForMultipleChoice",
					    "FunnelForPreTraining",
					    "FunnelForQuestionAnswering",
					    "FunnelForSequenceClassification",
					    "FunnelForTokenClassification",
					    "FunnelModel",
					    "FunnelPreTrainedModel",
					    "load_tf_weights_in_funnel",
					]

try:
					if not is_tf_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowerCamelCase__ :       Tuple						     =			[
					    "TF_FUNNEL_PRETRAINED_MODEL_ARCHIVE_LIST",
					    "TFFunnelBaseModel",
					    "TFFunnelForMaskedLM",
					    "TFFunnelForMultipleChoice",
					    "TFFunnelForPreTraining",
					    "TFFunnelForQuestionAnswering",
					    "TFFunnelForSequenceClassification",
					    "TFFunnelForTokenClassification",
					    "TFFunnelModel",
					    "TFFunnelPreTrainedModel",
					]


if TYPE_CHECKING:
					from .configuration_funnel import FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP, FunnelConfig
					from .tokenization_funnel import FunnelTokenizer

					try:
										if not is_tokenizers_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .tokenization_funnel_fast import FunnelTokenizerFast

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_funnel import (
										    FUNNEL_PRETRAINED_MODEL_ARCHIVE_LIST,
										    FunnelBaseModel,
										    FunnelForMaskedLM,
										    FunnelForMultipleChoice,
										    FunnelForPreTraining,
										    FunnelForQuestionAnswering,
										    FunnelForSequenceClassification,
										    FunnelForTokenClassification,
										    FunnelModel,
										    FunnelPreTrainedModel,
										    load_tf_weights_in_funnel,
										)

					try:
										if not is_tf_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_tf_funnel import (
										    TF_FUNNEL_PRETRAINED_MODEL_ARCHIVE_LIST,
										    TFFunnelBaseModel,
										    TFFunnelForMaskedLM,
										    TFFunnelForMultipleChoice,
										    TFFunnelForPreTraining,
										    TFFunnelForQuestionAnswering,
										    TFFunnelForSequenceClassification,
										    TFFunnelForTokenClassification,
										    TFFunnelModel,
										    TFFunnelPreTrainedModel,
										)

else:
					import sys

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





