


'''simple docstring'''



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


__A		=logging.get_logger(__name__)

__A		={
    '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 						_snake_case   (       a__    ,				a__		):
						lowerCAmelCase :Optional[int]						=   '''nat'''

						lowerCAmelCase :List[str]						=   {
						    '''num_attention_heads''': '''num_heads''',
						    '''num_hidden_layers''': '''num_layers''',
						}




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

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



'''simple docstring'''



import colorsys

from PIL import Image  # type: ignore







def       _UpperCamelCase (						UpperCamelCase__	, UpperCamelCase__	, UpperCamelCase__   ):
			UpperCAmelCase__					:   Optional[Any]       				=       x
			UpperCAmelCase__					:   Optional[int]       				=       y
			for step in range(UpperCamelCase__   ):  # noqa: B007
						UpperCAmelCase__					:   List[str]       				=       a * a - b * b + x
						UpperCAmelCase__					:   Optional[int]       				=       2 * a * b + y
						UpperCAmelCase__					:   int       				=       a_new

						# divergence happens for all complex number with an absolute value
						# greater than 4
						if a * a + b * b > 4:
									break
			return step / (max_step - 1)







def       _UpperCamelCase (						UpperCamelCase__   ):
			if distance == 1:
						return (0, 0, 0)
			else:
						return (2_5_5, 2_5_5, 2_5_5)







def       _UpperCamelCase (						UpperCamelCase__   ):
			if distance == 1:
						return (0, 0, 0)
			else:
						return tuple(round(i * 2_5_5   ) for i in colorsys.hsv_to_rgb(UpperCamelCase__	, 1	, 1   )   )







def       _UpperCamelCase (						UpperCamelCase__ = 8_0_0	, UpperCamelCase__ = 6_0_0	, UpperCamelCase__ = -0.6	, UpperCamelCase__ = 0	, UpperCamelCase__ = 3.2	, UpperCamelCase__ = 5_0	, UpperCamelCase__ = True	, ):
			UpperCAmelCase__					:   str       				=       Image.new("""RGB"""	, (image_width, image_height)   )
			UpperCAmelCase__					:   Optional[int]       				=       img.load()

			# loop through the image-coordinates
			for image_x in range(UpperCamelCase__   ):
						for image_y in range(UpperCamelCase__   ):
									# determine the figure-coordinates based on the image-coordinates
									UpperCAmelCase__					:   Union[str, Any]       				=       figure_width / image_width * image_height
									UpperCAmelCase__					:   Union[str, Any]       				=       figure_center_x + (image_x / image_width - 0.5) * figure_width
									UpperCAmelCase__					:   Tuple       				=       figure_center_y + (image_y / image_height - 0.5) * figure_height

									UpperCAmelCase__					:   List[str]       				=       get_distance(UpperCamelCase__	, UpperCamelCase__	, UpperCamelCase__   )

									# color the corresponding pixel based on the selected coloring-function
									if use_distance_color_coding:
												UpperCAmelCase__					:   Any       				=       get_color_coded_rgb(UpperCamelCase__   )
									else:
												UpperCAmelCase__					:   Tuple       				=       get_black_and_white_rgb(UpperCamelCase__   )

			return img


if __name__ == "__main__":
		import doctest

		doctest.testmod()

		# colored version, full figure
		__A		=get_image()

		# uncomment for colored version, different section, zoomed in
		# img = get_image(figure_center_x = -0.6, figure_center_y = -0.4,
		# figure_width = 0.8)

		# uncomment for black and white version, full figure
		# img = get_image(use_distance_color_coding = False)

		# uncomment to save the image
		# img.save("mandelbrot.png")

		img.show()