



import copy
from typing import Dict, List, Optional

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


SCREAMING_SNAKE_CASE_:Dict             =						{
    """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
}

SCREAMING_SNAKE_CASE_:int             =						logging.get_logger(__name__)






class SCREAMING_SNAKE_CASE__     (		SCREAMING_SNAKE_CASE__    ):




    '''simple docstring'''






    __lowerCamelCase			: Optional[Any]					=      "mask2former"
    __lowerCamelCase			: List[str]					=      ["swin"]
    __lowerCamelCase			: str					=      {"hidden_size": "hidden_dim"}






    def __init__(       self,		lowerCamelCase__ = None,		lowerCamelCase__ = 256,		lowerCamelCase__ = 256,		lowerCamelCase__ = 256,		lowerCamelCase__ = 1024,		lowerCamelCase__ = "relu",		lowerCamelCase__ = 6,		lowerCamelCase__ = 10,		lowerCamelCase__ = 8,		lowerCamelCase__ = 0.0,		lowerCamelCase__ = 2048,		lowerCamelCase__ = False,		lowerCamelCase__ = False,		lowerCamelCase__ = 4,		lowerCamelCase__ = 255,		lowerCamelCase__ = 100,		lowerCamelCase__ = 0.1,		lowerCamelCase__ = 2.0,		lowerCamelCase__ = 5.0,		lowerCamelCase__ = 5.0,		lowerCamelCase__ = 1_2544,		lowerCamelCase__ = 3.0,		lowerCamelCase__ = 0.75,		lowerCamelCase__ = 0.02,		lowerCamelCase__ = 1.0,		lowerCamelCase__ = True,		lowerCamelCase__ = [4, 8, 16, 32],		lowerCamelCase__ = None,		**lowerCamelCase__,		):
        if backbone_config is None:
            logger.info("""`backbone_config` is `None`. Initializing the config with the default `Swin` backbone."""		)
            A :       Tuple          =   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=lowerCamelCase__,		out_features=["""stage1""", """stage2""", """stage3""", """stage4"""],		)

        if isinstance(lowerCamelCase__,		lowerCamelCase__		):
            A :       int          =   backbone_config.pop("""model_type"""		)
            A :       Union[str, Any]          =   CONFIG_MAPPING[backbone_model_type]
            A :       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		)}'''		)

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

        super().__init__(**lowerCamelCase__		)






    @classmethod
    def 			_lowerCAmelCase					(       cls,		lowerCamelCase__,		**lowerCamelCase__		):
        return cls(
            backbone_config=lowerCamelCase__,		**lowerCamelCase__,		)






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







from ..utils import DummyObject, requires_backends






class SCREAMING_SNAKE_CASE__     (		metaclass=SCREAMING_SNAKE_CASE__    ):




    '''simple docstring'''






    __lowerCamelCase			: List[str]					=      ["torch", "transformers", "onnx"]






    def __init__(       self,		*lowerCamelCase__,		**lowerCamelCase__		):
        requires_backends(self,		["""torch""", """transformers""", """onnx"""]		)






    @classmethod
    def 			_lowerCAmelCase					(       cls,		*lowerCamelCase__,		**lowerCamelCase__		):
        requires_backends(cls,		["""torch""", """transformers""", """onnx"""]		)






    @classmethod
    def 			_lowerCAmelCase					(       cls,		*lowerCamelCase__,		**lowerCamelCase__		):
        requires_backends(cls,		["""torch""", """transformers""", """onnx"""]		)






class SCREAMING_SNAKE_CASE__     (		metaclass=SCREAMING_SNAKE_CASE__    ):




    '''simple docstring'''






    __lowerCamelCase			: Dict					=      ["torch", "transformers", "onnx"]






    def __init__(       self,		*lowerCamelCase__,		**lowerCamelCase__		):
        requires_backends(self,		["""torch""", """transformers""", """onnx"""]		)






    @classmethod
    def 			_lowerCAmelCase					(       cls,		*lowerCamelCase__,		**lowerCamelCase__		):
        requires_backends(cls,		["""torch""", """transformers""", """onnx"""]		)






    @classmethod
    def 			_lowerCAmelCase					(       cls,		*lowerCamelCase__,		**lowerCamelCase__		):
        requires_backends(cls,		["""torch""", """transformers""", """onnx"""]		)






class SCREAMING_SNAKE_CASE__     (		metaclass=SCREAMING_SNAKE_CASE__    ):




    '''simple docstring'''






    __lowerCamelCase			: Any					=      ["torch", "transformers", "onnx"]






    def __init__(       self,		*lowerCamelCase__,		**lowerCamelCase__		):
        requires_backends(self,		["""torch""", """transformers""", """onnx"""]		)






    @classmethod
    def 			_lowerCAmelCase					(       cls,		*lowerCamelCase__,		**lowerCamelCase__		):
        requires_backends(cls,		["""torch""", """transformers""", """onnx"""]		)






    @classmethod
    def 			_lowerCAmelCase					(       cls,		*lowerCamelCase__,		**lowerCamelCase__		):
        requires_backends(cls,		["""torch""", """transformers""", """onnx"""]		)






class SCREAMING_SNAKE_CASE__     (		metaclass=SCREAMING_SNAKE_CASE__    ):




    '''simple docstring'''






    __lowerCamelCase			: Optional[int]					=      ["torch", "transformers", "onnx"]






    def __init__(       self,		*lowerCamelCase__,		**lowerCamelCase__		):
        requires_backends(self,		["""torch""", """transformers""", """onnx"""]		)






    @classmethod
    def 			_lowerCAmelCase					(       cls,		*lowerCamelCase__,		**lowerCamelCase__		):
        requires_backends(cls,		["""torch""", """transformers""", """onnx"""]		)






    @classmethod
    def 			_lowerCAmelCase					(       cls,		*lowerCamelCase__,		**lowerCamelCase__		):
        requires_backends(cls,		["""torch""", """transformers""", """onnx"""]		)






class SCREAMING_SNAKE_CASE__     (		metaclass=SCREAMING_SNAKE_CASE__    ):




    '''simple docstring'''






    __lowerCamelCase			: Optional[int]					=      ["torch", "transformers", "onnx"]






    def __init__(       self,		*lowerCamelCase__,		**lowerCamelCase__		):
        requires_backends(self,		["""torch""", """transformers""", """onnx"""]		)






    @classmethod
    def 			_lowerCAmelCase					(       cls,		*lowerCamelCase__,		**lowerCamelCase__		):
        requires_backends(cls,		["""torch""", """transformers""", """onnx"""]		)






    @classmethod
    def 			_lowerCAmelCase					(       cls,		*lowerCamelCase__,		**lowerCamelCase__		):
        requires_backends(cls,		["""torch""", """transformers""", """onnx"""]		)






class SCREAMING_SNAKE_CASE__     (		metaclass=SCREAMING_SNAKE_CASE__    ):




    '''simple docstring'''






    __lowerCamelCase			: Optional[int]					=      ["torch", "transformers", "onnx"]






    def __init__(       self,		*lowerCamelCase__,		**lowerCamelCase__		):
        requires_backends(self,		["""torch""", """transformers""", """onnx"""]		)






    @classmethod
    def 			_lowerCAmelCase					(       cls,		*lowerCamelCase__,		**lowerCamelCase__		):
        requires_backends(cls,		["""torch""", """transformers""", """onnx"""]		)






    @classmethod
    def 			_lowerCAmelCase					(       cls,		*lowerCamelCase__,		**lowerCamelCase__		):
        requires_backends(cls,		["""torch""", """transformers""", """onnx"""]		)


