





'''simple docstring'''




import math







class   A_	:




 def      lowercase	(					self       :    Any	,			snake_case_       :    int	,			snake_case_       :    List[str]    ):
      _UpperCAmelCase     							=   0.0
      _UpperCAmelCase     							=   0.0
      for i in range(len(__UpperCamelCase    )    ):
           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      lowercase	(					self       :    Dict	,			snake_case_       :    Optional[Any]	,			snake_case_       :    Optional[Any]	,			snake_case_       :    Union[str, Any]	,			snake_case_       :    List[str]    ):


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





def 	UpperCAmelCase_							(					)		->       Dict:


     '''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(__SCREAMING_SNAKE_CASE       ):
          for j in range(len(__SCREAMING_SNAKE_CASE       )       ):
               # training sample
               _UpperCAmelCase     							=   training_samples[j]

               # Compute the winning vector
               _UpperCAmelCase     							=   self_organizing_map.get_winner(__SCREAMING_SNAKE_CASE			,     __SCREAMING_SNAKE_CASE       )

               # Update the winning vector
               _UpperCAmelCase     							=   self_organizing_map.update(__SCREAMING_SNAKE_CASE			,     __SCREAMING_SNAKE_CASE			,     __SCREAMING_SNAKE_CASE			,     __SCREAMING_SNAKE_CASE       )

    # classify test sample
     _UpperCAmelCase     							=   [0, 0, 0, 1]
     _UpperCAmelCase     							=   self_organizing_map.get_winner(__SCREAMING_SNAKE_CASE			,     __SCREAMING_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"""







import sys

from .dependency_versions_table import deps
from .utils.versions import require_version, require_version_core


# define which module versions we always want to check at run time
# (usually the ones defined in `install_requires` in setup.py)
#
# order specific notes:
# - tqdm must be checked before tokenizers

__SCREAMING_SNAKE_CASE    	="python tqdm regex requests packaging filelock numpy tokenizers".split()
if sys.version_info < (3, 7):
       pkgs_to_check_at_runtime.append("dataclasses")
if sys.version_info < (3, 8):
       pkgs_to_check_at_runtime.append("importlib_metadata")

for pkg in pkgs_to_check_at_runtime:
       if pkg in deps:
              if pkg == "tokenizers":
                     # must be loaded here, or else tqdm check may fail
                     from .utils import is_tokenizers_available

                     if not is_tokenizers_available():
                            continue  # not required, check version only if installed

              require_version_core(deps[pkg])
       else:
              raise ValueError(F"can't find {pkg} in {deps.keys()}, check dependency_versions_table.py")



def 			lowercase__(       __SCREAMING_SNAKE_CASE							:     int     ,			__SCREAMING_SNAKE_CASE							:     Union[str, Any]=None      ):
     require_version(deps[pkg]     ,			__SCREAMING_SNAKE_CASE      )

