



"""simple docstring"""







import math







class 				UpperCamelCase__       :




      """simple docstring"""




      def 					SCREAMING_SNAKE_CASE__			(				self    :				List[Any]   ,      SCREAMING_SNAKE_CASE_    :				list[list[float]]   ,      SCREAMING_SNAKE_CASE_    :				list[int]	):
        lowerCAmelCase_       :    Tuple								=			0.0
        lowerCAmelCase_       :    Union[str, Any]								=			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    :				List[str]   ,      SCREAMING_SNAKE_CASE_    :				list[list[int | float]]   ,      SCREAMING_SNAKE_CASE_    :				list[int]   ,      SCREAMING_SNAKE_CASE_    :				int   ,      SCREAMING_SNAKE_CASE_    :				float	):
        for i in range(len(SCREAMING_SNAKE_CASE_	)	):
          weights[j][i] += alpha * (sample[i] - weights[j][i])
        return weights




def     UpperCamelCase_   (   )						->       None:

  """simple docstring"""




  lowerCAmelCase_       :    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_       :    List[Any]								=			SelfOrganizingMap()
  lowerCAmelCase_       :    Tuple								=			3
  lowerCAmelCase_       :    Dict								=			0.5

  for _ in range(lowerCAmelCase__						):
    for j in range(len(lowerCAmelCase__						)						):
      # training sample
      lowerCAmelCase_       :    List[str]								=			training_samples[j]

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

      # Update the winning vector
      lowerCAmelCase_       :    int								=			self_organizing_map.update(lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__						)

    # classify test sample
  lowerCAmelCase_       :    Union[str, Any]								=			[0, 0, 0, 1]
  lowerCAmelCase_       :    List[str]								=			self_organizing_map.get_winner(lowerCAmelCase__   ,       lowerCAmelCase__						)

  # 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"""







from diffusers.utils.testing_utils import require_onnxruntime







@require_onnxruntime
class 				UpperCamelCase__       :




      """simple docstring"""




      pass





