
'''simple docstring'''







import copy
from typing import Dict, Optional

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


__SCREAMING_SNAKE_CASE		:  Tuple        =      logging.get_logger(__name__)

__SCREAMING_SNAKE_CASE		:  Union[str, Any]        =      {
    'shi-labs/oneformer_ade20k_swin_tiny': (
        'https://huggingface.co/shi-labs/oneformer_ade20k_swin_tiny/blob/main/config.json'
    ),
    # See all OneFormer models at https://huggingface.co/models?filter=oneformer
}
class  SCREAMING_SNAKE_CASE__       (  __UpperCamelCase   ):
	lowercase__	    =							"oneformer"
	lowercase__	    =							{"hidden_size": "hidden_dim"}
	def __init__(				self  ,    __UpperCamelCase = None  ,    __UpperCamelCase = 255  ,    __UpperCamelCase = 150  ,    __UpperCamelCase = 0.1  ,    __UpperCamelCase = 2.0  ,    __UpperCamelCase = 5.0  ,    __UpperCamelCase = 5.0  ,    __UpperCamelCase = 0.5  ,    __UpperCamelCase = 0.0_7  ,    __UpperCamelCase = 1_2544  ,    __UpperCamelCase = 3.0  ,    __UpperCamelCase = 0.7_5  ,    __UpperCamelCase = 0.0_2  ,    __UpperCamelCase = 1.0  ,    __UpperCamelCase = 1E-05  ,    __UpperCamelCase = False  ,    __UpperCamelCase = True  ,    __UpperCamelCase = True  ,    __UpperCamelCase = [4, 8, 16, 32]  ,    __UpperCamelCase = 77  ,    __UpperCamelCase = 256  ,    __UpperCamelCase = 77  ,    __UpperCamelCase = 6  ,    __UpperCamelCase = 4_9408  ,    __UpperCamelCase = 2  ,    __UpperCamelCase = 16  ,    __UpperCamelCase = 256  ,    __UpperCamelCase = 256  ,    __UpperCamelCase = 256  ,    __UpperCamelCase = 1024  ,    __UpperCamelCase = "GN"  ,    __UpperCamelCase = 6  ,    __UpperCamelCase = 10  ,    __UpperCamelCase = True  ,    __UpperCamelCase = 8  ,    __UpperCamelCase = 0.1  ,    __UpperCamelCase = 2048  ,    __UpperCamelCase = False  ,    __UpperCamelCase = False  ,    __UpperCamelCase = 2  ,    __UpperCamelCase = 4  ,    **__UpperCamelCase  ,    ):



					'''simple docstring'''






					if backbone_config is None:
									logger.info("""`backbone_config` is unset. Initializing the config with the default `Swin` backbone."""			)
									__a       :     int								=	CONFIG_MAPPING["""swin"""](
									    image_size=224  ,    in_channels=3  ,    patch_size=4  ,    embed_dim=96  ,    depths=[2, 2, 6, 2]  ,    num_heads=[3, 6, 12, 24]  ,    window_size=7  ,    drop_path_rate=0.3  ,    use_absolute_embeddings=__UpperCamelCase  ,    out_features=["""stage1""", """stage2""", """stage3""", """stage4"""]  ,    )
					elif isinstance(__UpperCamelCase  ,    __UpperCamelCase			):
									__a       :     str								=	backbone_config.get("""model_type"""			)
									__a       :     int								=	CONFIG_MAPPING[backbone_model_type]
									__a       :     Tuple								=	config_class.from_dict(__UpperCamelCase			)

					__a       :     Tuple								=	backbone_config

					__a       :     Union[str, Any]								=	ignore_value
					__a       :     Any								=	num_queries
					__a       :     str								=	no_object_weight
					__a       :     str								=	class_weight
					__a       :     Dict								=	mask_weight
					__a       :     Tuple								=	dice_weight
					__a       :     Dict								=	contrastive_weight
					__a       :     Tuple								=	contrastive_temperature
					__a       :     List[Any]								=	train_num_points
					__a       :     int								=	oversample_ratio
					__a       :     List[Any]								=	importance_sample_ratio
					__a       :     Union[str, Any]								=	init_std
					__a       :     Union[str, Any]								=	init_xavier_std
					__a       :     Tuple								=	layer_norm_eps
					__a       :     Tuple								=	is_training
					__a       :     List[str]								=	use_auxiliary_loss
					__a       :     str								=	output_auxiliary_logits
					__a       :     Tuple								=	strides
					__a       :     List[Any]								=	task_seq_len
					__a       :     List[Any]								=	text_encoder_width
					__a       :     Optional[Any]								=	text_encoder_context_length
					__a       :     Any								=	text_encoder_num_layers
					__a       :     Any								=	text_encoder_vocab_size
					__a       :     List[str]								=	text_encoder_proj_layers
					__a       :     Union[str, Any]								=	text_encoder_n_ctx
					__a       :     List[str]								=	conv_dim
					__a       :     Dict								=	mask_dim
					__a       :     Any								=	hidden_dim
					__a       :     int								=	encoder_feedforward_dim
					__a       :     Tuple								=	norm
					__a       :     Tuple								=	encoder_layers
					__a       :     Dict								=	decoder_layers
					__a       :     Union[str, Any]								=	use_task_norm
					__a       :     Any								=	num_attention_heads
					__a       :     str								=	dropout
					__a       :     List[str]								=	dim_feedforward
					__a       :     Optional[int]								=	pre_norm
					__a       :     List[str]								=	enforce_input_proj
					__a       :     str								=	query_dec_layers
					__a       :     Dict								=	common_stride
					__a       :     Optional[int]								=	decoder_layers

					super().__init__(**__UpperCamelCase			)

	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     Dict								=	copy.deepcopy(self.__dict__			)
					__a       :     Optional[Any]								=	self.backbone_config.to_dict()
					__a       :     Optional[Any]								=	self.__class__.model_type
					return output

'''simple docstring'''







from typing import TYPE_CHECKING

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


__SCREAMING_SNAKE_CASE		:  Tuple        =      {
    'configuration_segformer': ['SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SegformerConfig', 'SegformerOnnxConfig']
}

try:
					if not is_vision_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__SCREAMING_SNAKE_CASE		:  Dict        =      ['SegformerFeatureExtractor']
					__SCREAMING_SNAKE_CASE		:  str        =      ['SegformerImageProcessor']

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__SCREAMING_SNAKE_CASE		:  List[str]        =      [
					    'SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST',
					    'SegformerDecodeHead',
					    'SegformerForImageClassification',
					    'SegformerForSemanticSegmentation',
					    'SegformerLayer',
					    'SegformerModel',
					    'SegformerPreTrainedModel',
					]

try:
					if not is_tf_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__SCREAMING_SNAKE_CASE		:  List[str]        =      [
					    'TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST',
					    'TFSegformerDecodeHead',
					    'TFSegformerForImageClassification',
					    'TFSegformerForSemanticSegmentation',
					    'TFSegformerModel',
					    'TFSegformerPreTrainedModel',
					]


if TYPE_CHECKING:
					from .configuration_segformer import SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, SegformerConfig, SegformerOnnxConfig

					try:
										if not is_vision_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .feature_extraction_segformer import SegformerFeatureExtractor
										from .image_processing_segformer import SegformerImageProcessor

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_segformer import (
										    SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
										    SegformerDecodeHead,
										    SegformerForImageClassification,
										    SegformerForSemanticSegmentation,
										    SegformerLayer,
										    SegformerModel,
										    SegformerPreTrainedModel,
										)
					try:
										if not is_tf_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_tf_segformer import (
										    TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
										    TFSegformerDecodeHead,
										    TFSegformerForImageClassification,
										    TFSegformerForSemanticSegmentation,
										    TFSegformerModel,
										    TFSegformerPreTrainedModel,
										)

else:
					import sys

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