





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


A 			=  logging.get_logger(__name__)

A 			=  {
    "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 				__lowercase			(			__UpperCAmelCase   ,      __UpperCAmelCase							):







					'''simple docstring'''




					__lowerCAmelCase  =  '''swin'''

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







					def __init__(						self	,			_UpperCAmelCase=224	,			_UpperCAmelCase=4	,			_UpperCAmelCase=3	,			_UpperCAmelCase=96	,			_UpperCAmelCase=[2, 2, 6, 2]	,			_UpperCAmelCase=[3, 6, 12, 24]	,			_UpperCAmelCase=7	,			_UpperCAmelCase=4.0	,			_UpperCAmelCase=True	,			_UpperCAmelCase=0.0	,			_UpperCAmelCase=0.0	,			_UpperCAmelCase=0.1	,			_UpperCAmelCase="gelu"	,			_UpperCAmelCase=False	,			_UpperCAmelCase=0.0_2	,			_UpperCAmelCase=1e-5	,			_UpperCAmelCase=32	,			_UpperCAmelCase=None	,			_UpperCAmelCase=None	,			**_UpperCAmelCase	,			):
									super().__init__(**lowerCAmelCase_     )

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






class 				__lowercase			(			__UpperCAmelCase							):







					'''simple docstring'''




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







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







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






"""simple docstring"""






# tests directory-specific settings - this file is run automatically
# by pytest before any tests are run

import sys
import warnings
from os.path import abspath, dirname, join


# allow having multiple repository checkouts and not needing to remember to rerun
# 'pip install -e .[dev]' when switching between checkouts and running tests.
A 			=  abspath(join(dirname(dirname(dirname(__file__))), '''src'''))
sys.path.insert(1, git_repo_path)


# silence FutureWarning warnings in tests since often we can't act on them until
# they become normal warnings - i.e. the tests still need to test the current functionality
warnings.simplefilter(action='''ignore''', category=FutureWarning)

def     __A      (			a_						:Tuple)		->		Dict:
				from transformers.testing_utils import pytest_addoption_shared

				pytest_addoption_shared(a_)






def     __A      (			a_						:Any)		->		int:
				from transformers.testing_utils import pytest_terminal_summary_main

				__a :						str			       =  terminalreporter.config.getoption('''--make-reports''')
				if make_reports:
								pytest_terminal_summary_main(a_   ,       id=a_)