

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


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

_SCREAMING_SNAKE_CASE    :      str          =			{
    'shi-labs/nat-mini-in1k-224': 'https://huggingface.co/shi-labs/nat-mini-in1k-224/resolve/main/config.json',
    # See all Nat models at https://huggingface.co/models?filter=nat
}







class  UpperCamelCase__		(    __lowercase,			__lowercase   ):







	'''simple docstring'''
	_lowerCAmelCase							       =				'''nat'''

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





	def __init__(			self				,       UpperCamelCase__=4				,       UpperCamelCase__=3				,       UpperCamelCase__=64				,       UpperCamelCase__=[3, 4, 6, 5]				,       UpperCamelCase__=[2, 4, 8, 16]				,       UpperCamelCase__=7				,       UpperCamelCase__=3.0				,       UpperCamelCase__=True				,       UpperCamelCase__=0.0				,       UpperCamelCase__=0.0				,       UpperCamelCase__=0.1				,       UpperCamelCase__="gelu"				,       UpperCamelCase__=0.0_2				,       UpperCamelCase__=1e-5				,       UpperCamelCase__=0.0				,       UpperCamelCase__=None				,       UpperCamelCase__=None				,       **UpperCamelCase__				,       ):
					super().__init__(**__a		)

					A__  :	Any         =							patch_size
					A__  :	Any         =							num_channels
					A__  :	int         =							embed_dim
					A__  :	Tuple         =							depths
					A__  :	Optional[int]         =							len(__a		)
					A__  :	Union[str, Any]         =							num_heads
					A__  :	Any         =							kernel_size
					A__  :	Dict         =							mlp_ratio
					A__  :	Tuple         =							qkv_bias
					A__  :	Optional[int]         =							hidden_dropout_prob
					A__  :	Tuple         =							attention_probs_dropout_prob
					A__  :	Optional[int]         =							drop_path_rate
					A__  :	Union[str, Any]         =							hidden_act
					A__  :	int         =							layer_norm_eps
					A__  :	List[Any]         =							initializer_range
					# we set the hidden_size attribute in order to make Nat work with VisionEncoderDecoderModel
					# this indicates the channel dimension after the last stage of the model
					A__  :	int         =							int(embed_dim * 2 ** (len(__a		) - 1)		)
					A__  :	Dict         =							layer_scale_init_value
					A__  :	int         =							["""stem"""] + [F"stage{idx}" for idx in range(1				,       len(__a		) + 1		)]
					A__  :	Optional[int]         =							get_aligned_output_features_output_indices(
					    out_features=__a				,       out_indices=__a				,       stage_names=self.stage_names		)

import json
import os
import tempfile

from transformers.testing_utils import check_json_file_has_correct_format







class  UpperCamelCase__		:







	'''simple docstring'''
	_lowerCAmelCase							       =				None





	def   __snake_case				(			self		):
					A__  :	Dict         =							self.feature_extraction_class(**self.feat_extract_dict		)
					A__  :	Tuple         =							json.loads(feat_extract.to_json_string()		)
					for key, value in self.feat_extract_dict.items():
									self.assertEqual(obj[key]				,       UpperCamelCase__		)





	def   __snake_case				(			self		):
					A__  :	Any         =							self.feature_extraction_class(**self.feat_extract_dict		)

					with tempfile.TemporaryDirectory() as tmpdirname:
									A__  :	Any         =							os.path.join(UpperCamelCase__				,       '''feat_extract.json'''		)
									feat_extract_first.to_json_file(UpperCamelCase__		)
									A__  :	Dict         =							self.feature_extraction_class.from_json_file(UpperCamelCase__		)

					self.assertEqual(feat_extract_second.to_dict()				,       feat_extract_first.to_dict()		)





	def   __snake_case				(			self		):
					A__  :	Any         =							self.feature_extraction_class(**self.feat_extract_dict		)

					with tempfile.TemporaryDirectory() as tmpdirname:
									A__  :	Any         =							feat_extract_first.save_pretrained(UpperCamelCase__		)[0]
									check_json_file_has_correct_format(UpperCamelCase__		)
									A__  :	Optional[int]         =							self.feature_extraction_class.from_pretrained(UpperCamelCase__		)

					self.assertEqual(feat_extract_second.to_dict()				,       feat_extract_first.to_dict()		)





	def   __snake_case				(			self		):
					A__  :	str         =							self.feature_extraction_class()
					self.assertIsNotNone(UpperCamelCase__		)