





'''simple docstring'''







import warnings
from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


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

lowerCAmelCase_					:    Any      	=			{
    'nvidia/segformer-b0-finetuned-ade-512-512': (
        'https://huggingface.co/nvidia/segformer-b0-finetuned-ade-512-512/resolve/main/config.json'
    ),
    # See all SegFormer models at https://huggingface.co/models?filter=segformer
}
class 				__SCREAMING_SNAKE_CASE  (lowerCamelCase_      ):






				"""simple docstring"""







				__a            ='segformer'




				def __init__(  self     :					Dict					,				__a     :					List[str]=3					,				__a     :					Tuple=4					,				__a     :					int=[2, 2, 2, 2]					,				__a     :					Optional[Any]=[8, 4, 2, 1]					,				__a     :					str=[32, 64, 1_60, 2_56]					,				__a     :					Union[str, Any]=[7, 3, 3, 3]					,				__a     :					int=[4, 2, 2, 2]					,				__a     :					str=[1, 2, 5, 8]					,				__a     :					List[str]=[4, 4, 4, 4]					,				__a     :					List[str]="gelu"					,				__a     :					Any=0.0					,				__a     :					Tuple=0.0					,				__a     :					List[str]=0.1					,				__a     :					Any=0.02					,				__a     :					Optional[Any]=0.1					,				__a     :					Dict=1e-6					,				__a     :					Any=2_56					,				__a     :					Any=2_55					,				**__a     :					Any					,				):
								super().__init__(**__a					)

								if "reshape_last_stage" in kwargs and kwargs["reshape_last_stage"] is False:
												warnings.warn(
												    "Reshape_last_stage is set to False in this config. This argument is deprecated and will soon be"
												    " removed, as the behaviour will default to that of reshape_last_stage = True."					,				__a					,				)

								_a								= num_channels
								_a								= num_encoder_blocks
								_a								= depths
								_a								= sr_ratios
								_a								= hidden_sizes
								_a								= patch_sizes
								_a								= strides
								_a								= mlp_ratios
								_a								= num_attention_heads
								_a								= hidden_act
								_a								= hidden_dropout_prob
								_a								= attention_probs_dropout_prob
								_a								= classifier_dropout_prob
								_a								= initializer_range
								_a								= drop_path_rate
								_a								= layer_norm_eps
								_a								= decoder_hidden_size
								_a								= kwargs.get("reshape_last_stage"					,				__a					)
								_a								= semantic_loss_ignore_index


class 				__SCREAMING_SNAKE_CASE  (lowerCamelCase_      ):






				"""simple docstring"""







				__a            =version.parse('1.11'      )




				@property
				def   UpperCamelCase__   (  self     :					Tuple					):
								return OrderedDict(
								    [
								        ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
								    ]					)




				@property
				def   UpperCamelCase__   (  self     :					Dict					):
								return 1e-4




				@property
				def   UpperCamelCase__   (  self     :					int					):
								return 12







'''simple docstring'''







import math
class 				__SCREAMING_SNAKE_CASE  :






				"""simple docstring"""







				def   UpperCamelCase__   (  self     :					List[str]					,				__a     :					list[list[float]]					,				__a     :					list[int]					):
								_a								= 0.0
								_a								= 0.0
								for i in range(len(__a					)					):
												da += math.pow((sample[i] - weights[0][i])					,				2					)
												da += math.pow((sample[i] - weights[1][i])					,				2					)
												return 0 if da > da else 1
								return 0




				def   UpperCamelCase__   (  self     :					List[Any]					,				__a     :					list[list[int | float]]					,				__a     :					list[int]					,				__a     :					int					,				__a     :					float					):
								for i in range(len(__a					)					):
												weights[j][i] += alpha * (sample[i] - weights[j][i])
								return weights






def  _lowerCamelCase				( )	->	None:
				# Training Examples ( m, n )
				_a								= [[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

				# weight initialization ( n, C )
				_a								= [[0.2, 0.6, 0.5, 0.9], [0.8, 0.4, 0.7, 0.3]]

				# training
				_a								= SelfOrganizingMap()
				_a								= 3
				_a								= 0.5

				for _ in range(lowercase						):
								for j in range(len(lowercase						)						):
												# training sample
												_a								= training_samples[j]

												# Compute the winning vector
												_a								= self_organizing_map.get_winner(lowercase    ,							lowercase						)

												# Update the winning vector
												_a								= self_organizing_map.update(lowercase    ,							lowercase    ,							lowercase    ,							lowercase						)

    # classify test sample
				_a								= [0, 0, 0, 1]
				_a								= self_organizing_map.get_winner(lowercase    ,							lowercase						)

				# results
				print(F'Clusters that the test sample belongs to : {winner}'						)
				print(F'Weights that have been trained : {weights}'						)


# running the main() function
if __name__ == "__main__":
					main()
