



"""simple docstring"""





from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


__lowerCAmelCase       :					int      					=					{
    '''configuration_bloom''': ['''BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BloomConfig''', '''BloomOnnxConfig'''],
}
try:
					if not is_tokenizers_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__lowerCAmelCase       :					List[Any]      					=					['''BloomTokenizerFast''']

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__lowerCAmelCase       :					Dict      					=					[
					    '''BLOOM_PRETRAINED_MODEL_ARCHIVE_LIST''',
					    '''BloomForCausalLM''',
					    '''BloomModel''',
					    '''BloomPreTrainedModel''',
					    '''BloomForSequenceClassification''',
					    '''BloomForTokenClassification''',
					    '''BloomForQuestionAnswering''',
					]

if TYPE_CHECKING:
					from .configuration_bloom import BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP, BloomConfig, BloomOnnxConfig

					try:
										if not is_tokenizers_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .tokenization_bloom_fast import BloomTokenizerFast

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_bloom import (
										    BLOOM_PRETRAINED_MODEL_ARCHIVE_LIST,
										    BloomForCausalLM,
										    BloomForQuestionAnswering,
										    BloomForSequenceClassification,
										    BloomForTokenClassification,
										    BloomModel,
										    BloomPreTrainedModel,
										)

else:
					import sys

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






"""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


__lowerCAmelCase       :					Tuple      					=					logging.get_logger(__name__)

__lowerCAmelCase       :					Dict      					=					{
    '''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    _lowerCAmelCase    (				SCREAMING_SNAKE_CASE__  ,				SCREAMING_SNAKE_CASE__		):





		"""simple docstring"""






		_lowerCamelCase			  =       '''swin'''

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





		def __init__(					self							,    _lowercase=2_2_4							,    _lowercase=4							,    _lowercase=3							,    _lowercase=9_6							,    _lowercase=[2, 2, 6, 2]							,    _lowercase=[3, 6, 1_2, 2_4]							,    _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=3_2							,    _lowercase=None							,    _lowercase=None							,    **_lowercase							,    ) ->						Union[str, Any]:







								'''simple docstring'''

								super().__init__(**_lowercase   )

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




class    _lowerCAmelCase    (				SCREAMING_SNAKE_CASE__		):





		"""simple docstring"""






		_lowerCamelCase			  =       version.parse('''1.11'''		)





		@property
		def    UpperCAmelCase__							(					self   ) ->						Mapping[str, Mapping[int, str]]:







								'''simple docstring'''

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





		@property
		def    UpperCAmelCase__							(					self   ) ->						float:







								'''simple docstring'''

								return 1E-4

