

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


lowerCAmelCase__		      =       logging.get_logger(__name__)

lowerCAmelCase__		      =       {
    '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__  (    lowerCamelCase_							,		lowerCamelCase_	):
			"""simple docstring"""







			__lowerCamelCase       				=				'swin'

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


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






							super().__init__(**__a				)

							A__						=	image_size
							A__						=	patch_size
							A__						=	num_channels
							A__						=	embed_dim
							A__						=	depths
							A__						=	len(__a				)
							A__						=	num_heads
							A__						=	window_size
							A__						=	mlp_ratio
							A__						=	qkv_bias
							A__						=	hidden_dropout_prob
							A__						=	attention_probs_dropout_prob
							A__						=	drop_path_rate
							A__						=	hidden_act
							A__						=	use_absolute_embeddings
							A__						=	layer_norm_eps
							A__						=	initializer_range
							A__						=	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
							A__						=	int(embed_dim * 2 ** (len(__a				) - 1)				)
							A__						=	["stem"] + [F'stage{idx}' for idx in range(1					,					len(__a				) + 1				)]
							A__			, A__						=	get_aligned_output_features_output_indices(
							    out_features=__a					,					out_indices=__a					,					stage_names=self.stage_names				)

class     a__  (    lowerCamelCase_	):
			"""simple docstring"""







			__lowerCamelCase       				=				version.parse('1.11'	)


			@property
			def    UpperCamelCase						(			self				)     ->  List[str]:
							'''simple docstring'''






							return OrderedDict(
							    [
							        ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
							    ]				)


			@property
			def    UpperCamelCase						(			self				)     ->  Optional[int]:
							'''simple docstring'''






							return 1e-4








'''simple docstring'''







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


lowerCAmelCase_					:    Optional[Any]      	=			logging.get_logger(__name__)

lowerCAmelCase_					:    List[str]      	=			{
    'microsoft/trocr-base-handwritten': (
        'https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config.json'
    ),
    # See all TrOCR models at https://huggingface.co/models?filter=trocr
}
class 				__SCREAMING_SNAKE_CASE  (lowerCamelCase_      ):






				"""simple docstring"""







				__a            ='trocr'
				__a            =['past_key_values']
				__a            ={
				    'num_attention_heads': 'decoder_attention_heads',
				    'hidden_size': 'd_model',
				    'num_hidden_layers': 'decoder_layers',
				}




				def __init__(  self     :					Optional[int]					,				__a     :					Any=5_02_65					,				__a     :					Optional[int]=10_24					,				__a     :					List[Any]=12					,				__a     :					str=16					,				__a     :					int=40_96					,				__a     :					Optional[Any]="gelu"					,				__a     :					Union[str, Any]=5_12					,				__a     :					Dict=0.1					,				__a     :					List[str]=0.0					,				__a     :					Union[str, Any]=0.0					,				__a     :					Any=2					,				__a     :					Union[str, Any]=0.02					,				__a     :					Any=0.0					,				__a     :					List[str]=True					,				__a     :					Optional[Any]=False					,				__a     :					Union[str, Any]=True					,				__a     :					Optional[Any]=True					,				__a     :					Any=1					,				__a     :					List[Any]=0					,				__a     :					Any=2					,				**__a     :					Optional[Any]					,				):
								_a								= vocab_size
								_a								= d_model
								_a								= decoder_layers
								_a								= decoder_attention_heads
								_a								= decoder_ffn_dim
								_a								= activation_function
								_a								= max_position_embeddings
								_a								= dropout
								_a								= attention_dropout
								_a								= activation_dropout
								_a								= init_std
								_a								= decoder_layerdrop
								_a								= use_cache
								_a								= scale_embedding
								_a								= use_learned_position_embeddings
								_a								= layernorm_embedding

								super().__init__(
								    pad_token_id=__a					,				bos_token_id=__a					,				eos_token_id=__a					,				decoder_start_token_id=__a					,				**__a					,				)
