
import math






class        SCREAMING_SNAKE_CASE__    :

							"""simple docstring"""






							def     A__		(  self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_			)->   int:





													'''simple docstring'''






													__UpperCamelCase       =			0.0
													__UpperCamelCase       =			0.0
													for i in range(len(SCREAMING_SNAKE_CASE_			)			):
																			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     A__		(  self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_			)->   list[list[int | float]]:





													'''simple docstring'''






													for i in range(len(SCREAMING_SNAKE_CASE_			)			):
																			weights[j][i] += alpha * (sample[i] - weights[j][i])
													return weights





def 	A_ (							)      ->    None:



						'''simple docstring'''

						__UpperCamelCase       =			[[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

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

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

																		# Compute the winning vector
																		__UpperCamelCase       =			self_organizing_map.get_winner(snake_case ,      snake_case )

																		# Update the winning vector
																		__UpperCamelCase       =			self_organizing_map.update(snake_case ,      snake_case ,      snake_case ,      snake_case )

    # classify test sample
						__UpperCamelCase       =			[0, 0, 0, 1]
						__UpperCamelCase       =			self_organizing_map.get_winner(snake_case ,      snake_case )

						# 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()






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowercase__							:							int									=			{
    "configuration_git": ["GIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "GitConfig", "GitVisionConfig"],
    "processing_git": ["GitProcessor"],
}

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				lowercase__							:							Tuple									=			[
				    "GIT_PRETRAINED_MODEL_ARCHIVE_LIST",
				    "GitForCausalLM",
				    "GitModel",
				    "GitPreTrainedModel",
				    "GitVisionModel",
				]

if TYPE_CHECKING:
				from .configuration_git import GIT_PRETRAINED_CONFIG_ARCHIVE_MAP, GitConfig, GitVisionConfig
				from .processing_git import GitProcessor

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_git import (
								    GIT_PRETRAINED_MODEL_ARCHIVE_LIST,
								    GitForCausalLM,
								    GitModel,
								    GitPreTrainedModel,
								    GitVisionModel,
								)

else:
				import sys

				lowercase__							:							Optional[Any]									=			_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)




