




"""simple docstring"""

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


_lowerCamelCase  :			Any        =       logging.get_logger(__name__)

_lowerCamelCase  :			List[str]        =       {
    'microsoft/focalnet-tiny': 'https://huggingface.co/microsoft/focalnet-tiny/resolve/main/config.json',
}

class        lowercase      (    __UpperCAmelCase     ,	__UpperCAmelCase):
				__lowerCAmelCase    :    Union[str, Any]         =   """focalnet"""







				def __init__(							self   :					int      ,     _lowerCamelCase   :					Tuple=2_24      ,     _lowerCamelCase   :					Union[str, Any]=4      ,     _lowerCamelCase   :					Any=3      ,     _lowerCamelCase   :					Optional[int]=96      ,     _lowerCamelCase   :					Dict=False      ,     _lowerCamelCase   :					List[str]=[1_92, 3_84, 7_68, 7_68]      ,     _lowerCamelCase   :					str=[2, 2, 6, 2]      ,     _lowerCamelCase   :					List[str]=[2, 2, 2, 2]      ,     _lowerCamelCase   :					Any=[3, 3, 3, 3]      ,     _lowerCamelCase   :					Tuple="gelu"      ,     _lowerCamelCase   :					Tuple=4.0      ,     _lowerCamelCase   :					Any=0.0      ,     _lowerCamelCase   :					List[str]=0.1      ,     _lowerCamelCase   :					str=False      ,     _lowerCamelCase   :					Optional[int]=1E-4      ,     _lowerCamelCase   :					Dict=False      ,     _lowerCamelCase   :					Any=False      ,     _lowerCamelCase   :					List[Any]=False      ,     _lowerCamelCase   :					Tuple=0.02      ,     _lowerCamelCase   :					Tuple=1E-5      ,     _lowerCamelCase   :					Optional[int]=32      ,     _lowerCamelCase   :					int=None      ,     _lowerCamelCase   :					Optional[int]=None      ,     **_lowerCamelCase   :					str      ,     ):



					"""simple docstring"""

					super().__init__(**_lowerCamelCase       )

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











"""simple docstring"""

from typing import Any

import numpy as np

def 		lowercase_      (		_UpperCAmelCase	):




	"""simple docstring"""






	return np.array_equal(_UpperCAmelCase  ,      matrix.conjugate().T	)

def 		lowercase_      (		_UpperCAmelCase  ,      _UpperCAmelCase	):




	"""simple docstring"""






	A_  :				Tuple	   =		v.conjugate().T
	A_  :				Tuple	   =		v_star.dot(_UpperCAmelCase	)
	assert isinstance(_UpperCAmelCase  ,      np.ndarray	)
	return (v_star_dot.dot(_UpperCAmelCase	)) / (v_star.dot(_UpperCAmelCase	))

def 		lowercase_      (		):




	"""simple docstring"""






	A_  :				Optional[Any]	   =		np.array([[2, 2 + 1J, 4], [2 - 1J, 3, 1J], [4, -1J, 1]]	)
	A_  :				str	   =		np.array([[1], [2], [3]]	)
	assert is_hermitian(_UpperCAmelCase	), f"""{a} is not hermitian."""
	print(rayleigh_quotient(_UpperCAmelCase  ,      _UpperCAmelCase	)	)

	A_  :				int	   =		np.array([[1, 2, 4], [2, 3, -1], [4, -1, 1]]	)
	assert is_hermitian(_UpperCAmelCase	), f"""{a} is not hermitian."""
	assert rayleigh_quotient(_UpperCAmelCase  ,      _UpperCAmelCase	) == float(3	)


if __name__ == "__main__":
		import doctest

		doctest.testmod()
		tests()





