


'''simple docstring'''
from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


__snake_case				 =	logging.get_logger(__name__)

__snake_case				 =	{
    '''microsoft/focalnet-tiny''': '''https://huggingface.co/microsoft/focalnet-tiny/resolve/main/config.json''',
}
class   lowercase      (				A__      ,						A__   ):

		"""simple docstring"""

		_a       					=							'focalnet'




		def __init__(						self       ,  UpperCamelCase_=224       ,  UpperCamelCase_=4       ,  UpperCamelCase_=3       ,  UpperCamelCase_=96       ,  UpperCamelCase_=False       ,  UpperCamelCase_=[192, 384, 768, 768]       ,  UpperCamelCase_=[2, 2, 6, 2]       ,  UpperCamelCase_=[2, 2, 2, 2]       ,  UpperCamelCase_=[3, 3, 3, 3]       ,  UpperCamelCase_="gelu"       ,  UpperCamelCase_=4.0       ,  UpperCamelCase_=0.0       ,  UpperCamelCase_=0.1       ,  UpperCamelCase_=False       ,  UpperCamelCase_=1e-4       ,  UpperCamelCase_=False       ,  UpperCamelCase_=False       ,  UpperCamelCase_=False       ,  UpperCamelCase_=0.02       ,  UpperCamelCase_=1e-5       ,  UpperCamelCase_=32       ,  UpperCamelCase_=None       ,  UpperCamelCase_=None       ,  **UpperCamelCase_       ,  ):

							'''simple docstring'''


							super().__init__(**UpperCamelCase_				)

							UpperCamelCase__  :str				   =					image_size
							UpperCamelCase__  :Dict				   =					patch_size
							UpperCamelCase__  :Optional[int]				   =					num_channels
							UpperCamelCase__  :List[str]				   =					embed_dim
							UpperCamelCase__  :int				   =					use_conv_embed
							UpperCamelCase__  :Union[str, Any]				   =					hidden_sizes
							UpperCamelCase__  :List[Any]				   =					depths
							UpperCamelCase__  :Tuple				   =					focal_levels
							UpperCamelCase__  :int				   =					focal_windows
							UpperCamelCase__  :Dict				   =					hidden_act
							UpperCamelCase__  :int				   =					mlp_ratio
							UpperCamelCase__  :Tuple				   =					hidden_dropout_prob
							UpperCamelCase__  :List[Any]				   =					drop_path_rate
							UpperCamelCase__  :Dict				   =					use_layerscale
							UpperCamelCase__  :Dict				   =					layerscale_value
							UpperCamelCase__  :Union[str, Any]				   =					use_post_layernorm
							UpperCamelCase__  :Optional[Any]				   =					use_post_layernorm_in_modulation
							UpperCamelCase__  :int				   =					normalize_modulator
							UpperCamelCase__  :str				   =					initializer_range
							UpperCamelCase__  :Optional[Any]				   =					layer_norm_eps
							UpperCamelCase__  :int				   =					encoder_stride
							UpperCamelCase__  :List[Any]				   =					['''stem'''] + [F'''stage{idx}''' for idx in range(1       ,  len(self.depths				) + 1				)]
							UpperCamelCase__   ,							UpperCamelCase__  :Optional[Any]				   =					get_aligned_output_features_output_indices(
							    out_features=UpperCamelCase_       ,  out_indices=UpperCamelCase_       ,  stage_names=self.stage_names				)



'''simple docstring'''
import importlib
import os
import sys


# This is required to make the module import works (when the python process is running from the root of the repo)
sys.path.append('''.''')


def      a (     __a  )    ->      List[str]:



					'''simple docstring'''






					UpperCamelCase__  :int				   =					test_file.split(os.path.sep  )
					if components[0:2] != ["tests", "models"]:
										raise ValueError(
										    '''`test_file` should start with `tests/models/` (with `/` being the OS specific path separator). Got '''
										    f'''{test_file} instead.'''  )
					UpperCamelCase__  :List[Any]				   =					components[-1]
					if not test_fn.endswith('''py'''  ):
										raise ValueError(f'''`test_file` should be a python file. Got {test_fn} instead.'''  )
					if not test_fn.startswith('''test_modeling_'''  ):
										raise ValueError(
										    f'''`test_file` should point to a file name of the form `test_modeling_*.py`. Got {test_fn} instead.'''  )

					UpperCamelCase__  :Optional[Any]				   =					components[:-1] + [test_fn.replace('''.py'''					,   ''''''  )]
					UpperCamelCase__  :str				   =					'''.'''.join(__a  )

					return test_module_path


def      a (     __a  )    ->      Tuple:



					'''simple docstring'''






					UpperCamelCase__  :Dict				   =					get_module_path(__a  )
					UpperCamelCase__  :List[str]				   =					importlib.import_module(__a  )

					return test_module


def      a (     __a  )    ->      int:



					'''simple docstring'''






					UpperCamelCase__  :Dict				   =					[]
					UpperCamelCase__  :Optional[Any]				   =					get_test_module(__a  )
					for attr in dir(__a  ):
										if attr.endswith('''ModelTester'''  ):
															tester_classes.append(getattr(__a					,   __a  )  )

    # sort with class names
					return sorted(__a					,   key=lambda __a  : x.__name__  )


def      a (     __a  )    ->      List[Any]:



					'''simple docstring'''






					UpperCamelCase__  :List[Any]				   =					[]
					UpperCamelCase__  :Dict				   =					get_test_module(__a  )
					for attr in dir(__a  ):
										UpperCamelCase__  :Dict				   =					getattr(__a					,   __a  )
										# (TF/Flax)ModelTesterMixin is also an attribute in specific model test module. Let's exclude them by checking
										# `all_model_classes` is not empty (which also excludes other special classes).
										UpperCamelCase__  :Optional[int]				   =					getattr(__a					,   '''all_model_classes'''					,   []  )
										if len(__a  ) > 0:
															test_classes.append(__a  )

    # sort with class names
					return sorted(__a					,   key=lambda __a  : x.__name__  )


def      a (     __a  )    ->      Union[str, Any]:



					'''simple docstring'''






					UpperCamelCase__  :int				   =					get_test_classes(__a  )
					UpperCamelCase__  :Any				   =					set()
					for test_class in test_classes:
										model_classes.update(test_class.all_model_classes  )

					# sort with class names
					return sorted(__a					,   key=lambda __a  : x.__name__  )


def      a (     __a  )    ->      Dict:



					'''simple docstring'''






					UpperCamelCase__  :Optional[Any]				   =					test_class()
					if hasattr(__a					,   '''setUp'''  ):
										test.setUp()

					UpperCamelCase__  :Union[str, Any]				   =					None
					if hasattr(__a					,   '''model_tester'''  ):
										# `(TF/Flax)ModelTesterMixin` has this attribute default to `None`. Let's skip this case.
										if test.model_tester is not None:
															UpperCamelCase__  :List[str]				   =					test.model_tester.__class__

					return model_tester


def      a (     __a					,   __a  )    ->      Any:



					'''simple docstring'''






					UpperCamelCase__  :str				   =					get_test_classes(__a  )

					UpperCamelCase__  :List[str]				   =					[]
					for test_class in test_classes:
										if model_class in test_class.all_model_classes:
															target_test_classes.append(__a  )

    # sort with class names
					return sorted(__a					,   key=lambda __a  : x.__name__  )


def      a (     __a					,   __a  )    ->      Union[str, Any]:



					'''simple docstring'''






					UpperCamelCase__  :Optional[int]				   =					get_test_classes_for_model(__a					,   __a  )

					UpperCamelCase__  :List[str]				   =					[]
					for test_class in test_classes:
										UpperCamelCase__  :int				   =					get_model_tester_from_test_class(__a  )
										if tester_class is not None:
															tester_classes.append(__a  )

    # sort with class names
					return sorted(__a					,   key=lambda __a  : x.__name__  )


def      a (     __a  )    ->      int:



					'''simple docstring'''






					UpperCamelCase__  :Any				   =					get_test_classes(__a  )
					UpperCamelCase__  :Dict				   =					{test_class: get_model_tester_from_test_class(__a  ) for test_class in test_classes}
					return test_tester_mapping


def      a (     __a  )    ->      List[str]:



					'''simple docstring'''






					UpperCamelCase__  :Any				   =					get_model_classes(__a  )
					UpperCamelCase__  :Tuple				   =					{
					    model_class: get_test_classes_for_model(__a					,   __a  ) for model_class in model_classes
					}
					return model_test_mapping


def      a (     __a  )    ->      Tuple:



					'''simple docstring'''






					UpperCamelCase__  :List[str]				   =					get_model_classes(__a  )
					UpperCamelCase__  :Union[str, Any]				   =					{
					    model_class: get_tester_classes_for_model(__a					,   __a  ) for model_class in model_classes
					}
					return model_to_tester_mapping







def      a (     __a  )    ->      List[Any]:



					'''simple docstring'''






					if isinstance(__a					,   __a  ):
										return o
					elif isinstance(__a					,   __a  ):
										return o.__name__
					elif isinstance(__a					,   (list, tuple)  ):
										return [to_json(__a  ) for x in o]
					elif isinstance(__a					,   __a  ):
										return {to_json(__a  ): to_json(__a  ) for k, v in o.items()}
					else:
										return o