


'''simple docstring'''
from ..utils import DummyObject, requires_backends

class 						_lowerCamelCase					(    metaclass=snake_case_				):




 '''simple docstring'''
 __lowercase				:		int    							=						['''flax''', '''transformers''']


 def __init__(      self      ,      *__lowercase      ,      **__lowercase						):

  """simple docstring"""







  requires_backends(self      ,      ['flax', 'transformers']						)


 @classmethod
 def  snake_case__   (      cls      ,      *__lowercase      ,      **__lowercase						):

  """simple docstring"""







  requires_backends(cls      ,      ['flax', 'transformers']						)







 @classmethod
 def  snake_case__   (      cls      ,      *__lowercase      ,      **__lowercase						):

  """simple docstring"""







  requires_backends(cls      ,      ['flax', 'transformers']						)


class 						_lowerCamelCase					(    metaclass=snake_case_				):




 '''simple docstring'''
 __lowercase				:		Optional[Any]    							=						['''flax''', '''transformers''']


 def __init__(      self      ,      *__lowercase      ,      **__lowercase						):

  """simple docstring"""







  requires_backends(self      ,      ['flax', 'transformers']						)


 @classmethod
 def  snake_case__   (      cls      ,      *__lowercase      ,      **__lowercase						):

  """simple docstring"""







  requires_backends(cls      ,      ['flax', 'transformers']						)







 @classmethod
 def  snake_case__   (      cls      ,      *__lowercase      ,      **__lowercase						):

  """simple docstring"""







  requires_backends(cls      ,      ['flax', 'transformers']						)


class 						_lowerCamelCase					(    metaclass=snake_case_				):




 '''simple docstring'''
 __lowercase				:		List[str]    							=						['''flax''', '''transformers''']


 def __init__(      self      ,      *__lowercase      ,      **__lowercase						):

  """simple docstring"""







  requires_backends(self      ,      ['flax', 'transformers']						)


 @classmethod
 def  snake_case__   (      cls      ,      *__lowercase      ,      **__lowercase						):

  """simple docstring"""







  requires_backends(cls      ,      ['flax', 'transformers']						)







 @classmethod
 def  snake_case__   (      cls      ,      *__lowercase      ,      **__lowercase						):

  """simple docstring"""







  requires_backends(cls      ,      ['flax', 'transformers']						)


class 						_lowerCamelCase					(    metaclass=snake_case_				):




 '''simple docstring'''
 __lowercase				:		Optional[int]    							=						['''flax''', '''transformers''']


 def __init__(      self      ,      *__lowercase      ,      **__lowercase						):

  """simple docstring"""







  requires_backends(self      ,      ['flax', 'transformers']						)


 @classmethod
 def  snake_case__   (      cls      ,      *__lowercase      ,      **__lowercase						):

  """simple docstring"""







  requires_backends(cls      ,      ['flax', 'transformers']						)







 @classmethod
 def  snake_case__   (      cls      ,      *__lowercase      ,      **__lowercase						):

  """simple docstring"""







  requires_backends(cls      ,      ['flax', 'transformers']						)










'''simple docstring'''
import math

class 						_lowerCamelCase					:




 '''simple docstring'''


 def  snake_case__   (      self      ,      __lowercase      ,      __lowercase						):

  """simple docstring"""







  __A  :		List[str]       =			0.0
  __A  :		Optional[int]       =			0.0
  for i in range(len(__lowercase						)						):
   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  snake_case__   (      self      ,      __lowercase      ,      __lowercase      ,      __lowercase      ,      __lowercase						):

  """simple docstring"""







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


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

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

 # training
 __A  :		Optional[int]       =			SelfOrganizingMap()
 __A  :		int       =			3
 __A  :		Optional[Any]       =			0.5

 for _ in range(UpperCamelCase__			):
  for j in range(len(UpperCamelCase__			)			):
   # training sample
   __A  :		Dict       =			training_samples[j]

   # Compute the winning vector
   __A  :		List[Any]       =			self_organizing_map.get_winner(UpperCamelCase__,				UpperCamelCase__			)

   # Update the winning vector
   __A  :		Union[str, Any]       =			self_organizing_map.update(UpperCamelCase__,				UpperCamelCase__,				UpperCamelCase__,				UpperCamelCase__			)

    # classify test sample
 __A  :		int       =			[0, 0, 0, 1]
 __A  :		List[Any]       =			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()






