





import math
class 							SCREAMING_SNAKE_CASE  :


   def 			SCREAMING_SNAKE_CASE_				(       self     :							Optional[Any]     ,	a     :							list[list[float]]     ,	a     :							list[int]			)->  int:





     """simple docstring"""







     lowercase__           =    0.0
     lowercase__           =    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 			SCREAMING_SNAKE_CASE_				(       self     :							Any     ,	a     :							list[list[int | float]]     ,	a     :							list[int]     ,	a     :							int     ,	a     :							float			)->  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      __UpperCamelCase    ()							->  None:
  # Training Examples ( m, n )
  lowercase__           =    [[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

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

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

      # Compute the winning vector
      lowercase__           =    self_organizing_map.get_winner(__snake_case						,		__snake_case						)

      # Update the winning vector
      lowercase__           =    self_organizing_map.update(__snake_case						,		__snake_case						,		__snake_case						,		__snake_case						)

    # classify test sample
  lowercase__           =    [0, 0, 0, 1]
  lowercase__           =    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()







"""simple docstring"""






def      _lowercase							(    __snake_case   ,__snake_case      )		->  int:
			return int((input_a, input_a).count(1      ) != 0      )


def      _lowercase							(    )		->  None:
			assert or_gate(0   ,0      ) == 0
			assert or_gate(0   ,1      ) == 1
			assert or_gate(1   ,0      ) == 1
			assert or_gate(1   ,1      ) == 1


if __name__ == "__main__":
	print(or_gate(0, 1))
	print(or_gate(1, 0))
	print(or_gate(0, 0))
	print(or_gate(1, 1))