

"""simple docstring"""




from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


SCREAMING_SNAKE_CASE_     :			Dict	  =			logging.get_logger(__name__)

SCREAMING_SNAKE_CASE_     :			int	  =			{
    """microsoft/swin-tiny-patch4-window7-224""": (
        """https://huggingface.co/microsoft/swin-tiny-patch4-window7-224/resolve/main/config.json"""
    ),
    # See all Swin models at https://huggingface.co/models?filter=swin
}


class 		_A       (			SCREAMING_SNAKE_CASE__				,       SCREAMING_SNAKE_CASE__					):
      __a								=	'swin'

      __a								=	{
          'num_attention_heads': 'num_heads',
          'num_hidden_layers': 'num_layers',
      }





      def __init__(  self    ,						SCREAMING_SNAKE_CASE__=224    ,						SCREAMING_SNAKE_CASE__=4    ,						SCREAMING_SNAKE_CASE__=3    ,						SCREAMING_SNAKE_CASE__=96    ,						SCREAMING_SNAKE_CASE__=[2, 2, 6, 2]    ,						SCREAMING_SNAKE_CASE__=[3, 6, 12, 24]    ,						SCREAMING_SNAKE_CASE__=7    ,						SCREAMING_SNAKE_CASE__=4.0    ,						SCREAMING_SNAKE_CASE__=True    ,						SCREAMING_SNAKE_CASE__=0.0    ,						SCREAMING_SNAKE_CASE__=0.0    ,						SCREAMING_SNAKE_CASE__=0.1    ,						SCREAMING_SNAKE_CASE__="gelu"    ,						SCREAMING_SNAKE_CASE__=False    ,						SCREAMING_SNAKE_CASE__=0.02    ,						SCREAMING_SNAKE_CASE__=1e-5    ,						SCREAMING_SNAKE_CASE__=32    ,						SCREAMING_SNAKE_CASE__=None    ,						SCREAMING_SNAKE_CASE__=None    ,						**SCREAMING_SNAKE_CASE__    ,						)   ->					Optional[Any]:
         super().__init__(**snake_case__		)

         lowerCamelCase__						=			image_size
         lowerCamelCase__						=			patch_size
         lowerCamelCase__						=			num_channels
         lowerCamelCase__						=			embed_dim
         lowerCamelCase__						=			depths
         lowerCamelCase__						=			len(snake_case__		)
         lowerCamelCase__						=			num_heads
         lowerCamelCase__						=			window_size
         lowerCamelCase__						=			mlp_ratio
         lowerCamelCase__						=			qkv_bias
         lowerCamelCase__						=			hidden_dropout_prob
         lowerCamelCase__						=			attention_probs_dropout_prob
         lowerCamelCase__						=			drop_path_rate
         lowerCamelCase__						=			hidden_act
         lowerCamelCase__						=			use_absolute_embeddings
         lowerCamelCase__						=			layer_norm_eps
         lowerCamelCase__						=			initializer_range
         lowerCamelCase__						=			encoder_stride
         # we set the hidden_size attribute in order to make Swin work with VisionEncoderDecoderModel
         # this indicates the channel dimension after the last stage of the model
         lowerCamelCase__						=			int(embed_dim * 2 ** (len(snake_case__		) - 1)		)
         lowerCamelCase__						=			["stem"] + [f'stage{idx}' for idx in range(1    ,						len(snake_case__		) + 1		)]
         lowerCamelCase__						=			get_aligned_output_features_output_indices(
             out_features=snake_case__    ,						out_indices=snake_case__    ,						stage_names=self.stage_names		)




class 		_A       (			SCREAMING_SNAKE_CASE__					):
      __a								=	version.parse('1.11'					)





      @property
      def 					_lowerCamelCase  (  self		)   ->					Optional[Any]:
         return OrderedDict(
             [
                 ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
             ]		)





      @property
      def 					_lowerCamelCase  (  self		)   ->					int:
         return 1e-4







"""simple docstring"""




import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging


SCREAMING_SNAKE_CASE_     :			Dict	  =			logging.get_logger(__name__)


class 		_A       (			__a					):
      __a								=	'encoder-decoder'
      __a								=	True





      def __init__(  self    ,						**SCREAMING_SNAKE_CASE__		)   ->					Optional[int]:
         super().__init__(**SCREAMING_SNAKE_CASE__		)
         assert (
             "encoder" in kwargs and "decoder" in kwargs
         ), "Config has to be initialized with encoder and decoder config"
         lowerCamelCase__						=			kwargs.pop("encoder"		)
         lowerCamelCase__						=			encoder_config.pop("model_type"		)
         lowerCamelCase__						=			kwargs.pop("decoder"		)
         lowerCamelCase__						=			decoder_config.pop("model_type"		)

         from ..auto.configuration_auto import AutoConfig

         lowerCamelCase__						=			AutoConfig.for_model(SCREAMING_SNAKE_CASE__    ,						**SCREAMING_SNAKE_CASE__		)
         lowerCamelCase__						=			AutoConfig.for_model(SCREAMING_SNAKE_CASE__    ,						**SCREAMING_SNAKE_CASE__		)
         lowerCamelCase__						=			True





      @classmethod
      def 					_lowerCamelCase  (  cls    ,						SCREAMING_SNAKE_CASE__    ,						SCREAMING_SNAKE_CASE__    ,						**SCREAMING_SNAKE_CASE__		)   ->					PretrainedConfig:
         logger.info("Set `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config"		)
         lowerCamelCase__						=			True
         lowerCamelCase__						=			True

         return cls(encoder=encoder_config.to_dict()    ,						decoder=decoder_config.to_dict()    ,						**SCREAMING_SNAKE_CASE__		)





      def 					_lowerCamelCase  (  self		)   ->					int:
         lowerCamelCase__						=			copy.deepcopy(self.__dict__		)
         lowerCamelCase__						=			self.encoder.to_dict()
         lowerCamelCase__						=			self.decoder.to_dict()
         lowerCamelCase__						=			self.__class__.model_type
         return output




