






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


__lowerCamelCase      :    str   		=   logging.get_logger(__name__)

__lowerCamelCase      :    List[Any]   		=   {
    """facebook/convnextv2-tiny-1k-224""": """https://huggingface.co/facebook/convnextv2-tiny-1k-224/resolve/main/config.json""",
}



class 							SCREAMING_SNAKE_CASE__		(       UpperCamelCase_				,     UpperCamelCase_		):





					"""simple docstring"""






					a_			=	"convnextv2"



					def __init__(      self  :						List[Any]							,	__A  :						List[Any]=3							,	__A  :						Any=4							,	__A  :						Union[str, Any]=4							,	__A  :						Union[str, Any]=None							,	__A  :						int=None							,	__A  :						Optional[int]="gelu"							,	__A  :						Optional[Any]=0.0_2							,	__A  :						Dict=1e-1_2							,	__A  :						List[Any]=0.0							,	__A  :						List[str]=2_2_4							,	__A  :						Any=None							,	__A  :						Union[str, Any]=None							,	**__A  :						Any							,	):
						super().__init__(**__A )

						snake_case__				:   Optional[Any]     =						num_channels
						snake_case__				:   int     =						patch_size
						snake_case__				:   str     =						num_stages
						snake_case__				:   Optional[Any]     =						[9_6, 1_9_2, 3_8_4, 7_6_8] if hidden_sizes is None else hidden_sizes
						snake_case__				:   Union[str, Any]     =						[3, 3, 9, 3] if depths is None else depths
						snake_case__				:   Tuple     =						hidden_act
						snake_case__				:   str     =						initializer_range
						snake_case__				:   int     =						layer_norm_eps
						snake_case__				:   str     =						drop_path_rate
						snake_case__				:   int     =						image_size
						snake_case__				:   Union[str, Any]     =						["stem"] + [f'''stage{idx}''' for idx in range(1							,	len(self.depths ) + 1 )]
						snake_case__,		snake_case__				:   Optional[Any]     =						get_aligned_output_features_output_indices(
						    out_features=__A							,	out_indices=__A							,	stage_names=self.stage_names )











import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch


if is_torch_available():
	import torch

	from transformers.activations import gelu_new, gelu_python, get_activation



@require_torch
class 							SCREAMING_SNAKE_CASE__		(       unittest.TestCase		):





					"""simple docstring"""






					def  _lowercase  (      self  :						Tuple ):
						snake_case__				:   List[str]     =						torch.tensor([-1_0_0, -1, -0.1, 0, 0.1, 1.0, 1_0_0] )
						snake_case__				:   Tuple     =						get_activation("gelu" )
						self.assertTrue(torch.allclose(gelu_python(__A )							,	torch_builtin(__A ) ) )
						self.assertFalse(torch.allclose(gelu_python(__A )							,	gelu_new(__A ) ) )



					def  _lowercase  (      self  :						Dict ):
						snake_case__				:   str     =						torch.tensor([-1_0_0, -1, -0.1, 0, 0.1, 1.0, 1_0_0] )
						snake_case__				:   Union[str, Any]     =						get_activation("gelu" )
						snake_case__				:   int     =						get_activation("gelu_10" )

						snake_case__				:   Optional[int]     =						torch_builtin(__A )
						snake_case__				:   Dict     =						geluaa(__A )

						snake_case__				:   Optional[Any]     =						torch.where(y_gelu_aa < 1_0.0							,	1							,	0 )

						self.assertTrue(torch.max(__A ).item() == 1_0.0 )
						self.assertTrue(torch.allclose(y_gelu * clipped_mask							,	y_gelu_aa * clipped_mask ) )



					def  _lowercase  (      self  :						str ):
						get_activation("gelu" )
						get_activation("gelu_10" )
						get_activation("gelu_fast" )
						get_activation("gelu_new" )
						get_activation("gelu_python" )
						get_activation("gelu_pytorch_tanh" )
						get_activation("linear" )
						get_activation("mish" )
						get_activation("quick_gelu" )
						get_activation("relu" )
						get_activation("sigmoid" )
						get_activation("silu" )
						get_activation("swish" )
						get_activation("tanh" )
						with self.assertRaises(__A ):
							get_activation("bogus" )
						with self.assertRaises(__A ):
							get_activation(__A )






					def  _lowercase  (      self  :						List[str] ):
						snake_case__				:   List[str]     =						get_activation("gelu" )
						snake_case__				:   Any     =						1
						snake_case__				:   Union[str, Any]     =						get_activation("gelu" )
						self.assertEqual(acta.a							,	1 )
						with self.assertRaises(__A ):
							snake_case__				:   int     =						acta.a



