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


lowercase_     :   List[str] 				=				logging.get_logger(__name__)

lowercase_     :   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  =      "swin"

    __a  =      {
        "num_attention_heads": "num_heads",
        "num_hidden_layers": "num_layers",
    }
    def __init__(  self , lowerCAmelCase=224 , lowerCAmelCase=4 , lowerCAmelCase=3 , lowerCAmelCase=96 , lowerCAmelCase=[2, 2, 6, 2] , lowerCAmelCase=[3, 6, 12, 24] , lowerCAmelCase=7 , lowerCAmelCase=4.0 , lowerCAmelCase=True , lowerCAmelCase=0.0 , lowerCAmelCase=0.0 , lowerCAmelCase=0.1 , lowerCAmelCase="gelu" , lowerCAmelCase=False , lowerCAmelCase=0.02 , lowerCAmelCase=1e-5 , lowerCAmelCase=32 , lowerCAmelCase=None , lowerCAmelCase=None , **lowerCAmelCase , )       ->					Tuple:
     super().__init__(**lowerCAmelCase   )

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






class 		_lowerCamelCase		(   UpperCamelCase_    ):
    __a  =      version.parse("1.11"    )
    @property
    def 						UpperCamelCase_				(  self   )       ->					Mapping[str, Mapping[int, str]]:
     return OrderedDict(
         [
             ('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''}),
         ]   )



    @property
    def 						UpperCamelCase_				(  self   )       ->					float:
     return 1e-4


# 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.
lowercase_     :   List[str] 				=				abspath(join(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__      (	snake_case_ :		Optional[int]      ):
 from diffusers.utils.testing_utils import pytest_addoption_shared

 pytest_addoption_shared(snake_case_      )







def 			A__      (	snake_case_ :		Optional[int]      ):
 from diffusers.utils.testing_utils import pytest_terminal_summary_main

 SCREAMING_SNAKE_CASE__:   Optional[int]=      terminalreporter.config.getoption('''--make-reports'''      )
 if make_reports:
  pytest_terminal_summary_main(snake_case_       ,				id=snake_case_      )

