
"""simple docstring"""







import math




class 			A__	:

		def 							__lowerCamelCase							(				self	,		_SCREAMING_SNAKE_CASE	,		_SCREAMING_SNAKE_CASE			):
			__lowerCAmelCase      :						List[Any]						      =				0.0
			__lowerCAmelCase      :						Optional[int]						      =				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 							__lowerCamelCase							(				self	,		_SCREAMING_SNAKE_CASE	,		_SCREAMING_SNAKE_CASE	,		_SCREAMING_SNAKE_CASE	,		_SCREAMING_SNAKE_CASE			):
			for i in range(len(_SCREAMING_SNAKE_CASE			)			):
				weights[j][i] += alpha * (sample[i] - weights[j][i])
			return weights



def    __lowerCAmelCase    ():
	# Training Examples ( m, n )
	__lowerCAmelCase      :						Union[str, Any]						      =				[[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

	# weight initialization ( n, C )
	__lowerCAmelCase      :						List[Any]						      =				[[0.2, 0.6, 0.5, 0.9], [0.8, 0.4, 0.7, 0.3]]

	# training
	__lowerCAmelCase      :						Dict						      =				SelfOrganizingMap()
	__lowerCAmelCase      :						List[str]						      =				3
	__lowerCAmelCase      :						List[Any]						      =				0.5

	for _ in range(_UpperCamelCase		):
		for j in range(len(_UpperCamelCase		)		):
			# training sample
			__lowerCAmelCase      :						Optional[Any]						      =				training_samples[j]

			# Compute the winning vector
			__lowerCAmelCase      :						str						      =				self_organizing_map.get_winner(_UpperCamelCase	,  _UpperCamelCase		)

			# Update the winning vector
			__lowerCAmelCase      :						Optional[int]						      =				self_organizing_map.update(_UpperCamelCase	,  _UpperCamelCase	,  _UpperCamelCase	,  _UpperCamelCase		)

    # classify test sample
	__lowerCAmelCase      :						Optional[Any]						      =				[0, 0, 0, 1]
	__lowerCAmelCase      :						List[str]						      =				self_organizing_map.get_winner(_UpperCamelCase	,  _UpperCamelCase		)

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

"""simple docstring"""







lowerCamelCase__        =		"""0.21.0"""

from .accelerator import Accelerator
from .big_modeling import (
    cpu_offload,
    cpu_offload_with_hook,
    disk_offload,
    dispatch_model,
    init_empty_weights,
    init_on_device,
    load_checkpoint_and_dispatch,
)
from .data_loader import skip_first_batches
from .launchers import debug_launcher, notebook_launcher
from .state import PartialState
from .utils import (
    DeepSpeedPlugin,
    DistributedDataParallelKwargs,
    DistributedType,
    FullyShardedDataParallelPlugin,
    GradScalerKwargs,
    InitProcessGroupKwargs,
    find_executable_batch_size,
    infer_auto_device_map,
    is_rich_available,
    load_checkpoint_in_model,
    synchronize_rng_states,
)


if is_rich_available():
							from .utils import rich