



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


snake_case    :						Any  =logging.get_logger(__name__)

snake_case    :						Any  ={
    "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__  (	__UpperCAmelCase					,							__UpperCAmelCase						):
					__A     :    List[Any]           =						'swin'

					__A     :    Union[str, Any]           =						{
					    'num_attention_heads': 'num_heads',
					    'num_hidden_layers': 'num_layers',
					}







					def __init__(       self      :     List[Any]			,		_A      :     Union[str, Any]=224			,		_A      :     Union[str, Any]=4			,		_A      :     str=3			,		_A      :     Optional[int]=96			,		_A      :     List[str]=[2, 2, 6, 2]			,		_A      :     Dict=[3, 6, 12, 24]			,		_A      :     Dict=7			,		_A      :     Union[str, Any]=4.0			,		_A      :     Optional[int]=True			,		_A      :     Dict=0.0			,		_A      :     Dict=0.0			,		_A      :     Dict=0.1			,		_A      :     List[Any]="gelu"			,		_A      :     List[Any]=False			,		_A      :     List[Any]=0.02			,		_A      :     List[str]=1e-5			,		_A      :     Optional[Any]=32			,		_A      :     List[str]=None			,		_A      :     Optional[Any]=None			,		**_A      :     int			,		):
											super().__init__(**lowerCAmelCase_)

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




class 							lowerCAmelCase__  (	__UpperCAmelCase						):
					__A     :    List[Any]           =						version.parse('1.11'						)







					@property
					def  _lowercase			(       self      :     Dict):
											return OrderedDict(
											    [
											        ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
											    ])







					@property
					def  _lowercase			(       self      :     Tuple):
											return 1e-4




import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin




class 							lowerCAmelCase__  (	unittest.TestCase					,							UpperCamelCase						):







					def  _lowercase			(       self      :     List[Any]):
											A__	:							Optional[Any]						    = load_tool("text-classification")
											self.tool.setup()
											A__	:							Any						    = load_tool("text-classification"			,		remote=_A)







					def  _lowercase			(       self      :     List[Any]):
											A__	:							Optional[Any]						    = self.tool("That's quite cool"			,		["positive", "negative"])
											self.assertEqual(_A			,		"positive")







					def  _lowercase			(       self      :     List[str]):
											A__	:							Any						    = self.remote_tool("That's quite cool"			,		["positive", "negative"])
											self.assertEqual(_A			,		"positive")







					def  _lowercase			(       self      :     Optional[Any]):
											A__	:							List[str]						    = self.tool(text="That's quite cool"			,		labels=["positive", "negative"])
											self.assertEqual(_A			,		"positive")







					def  _lowercase			(       self      :     Tuple):
											A__	:							Union[str, Any]						    = self.remote_tool(text="That's quite cool"			,		labels=["positive", "negative"])
											self.assertEqual(_A			,		"positive")