


from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


_SCREAMING_SNAKE_CASE      :			Dict      				=   {"configuration_swin": ["SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP", "SwinConfig", "SwinOnnxConfig"]}


try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 _SCREAMING_SNAKE_CASE      :			str      				=   [
     "SWIN_PRETRAINED_MODEL_ARCHIVE_LIST",
     "SwinForImageClassification",
     "SwinForMaskedImageModeling",
     "SwinModel",
     "SwinPreTrainedModel",
     "SwinBackbone",
 ]

try:
 if not is_tf_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 _SCREAMING_SNAKE_CASE      :			str      				=   [
     "TF_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST",
     "TFSwinForImageClassification",
     "TFSwinForMaskedImageModeling",
     "TFSwinModel",
     "TFSwinPreTrainedModel",
 ]

if TYPE_CHECKING:
 from .configuration_swin import SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP, SwinConfig, SwinOnnxConfig

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_swin import (
      SWIN_PRETRAINED_MODEL_ARCHIVE_LIST,
      SwinBackbone,
      SwinForImageClassification,
      SwinForMaskedImageModeling,
      SwinModel,
      SwinPreTrainedModel,
  )

 try:
  if not is_tf_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_tf_swin import (
      TF_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST,
      TFSwinForImageClassification,
      TFSwinForMaskedImageModeling,
      TFSwinModel,
      TFSwinPreTrainedModel,
  )

else:
 import sys

 _SCREAMING_SNAKE_CASE      :			List[Any]      				=   _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)








import math

class   A__ :







    """simple docstring"""

    def 		a_      (	self      , __snake_case      , __snake_case   ):
         snake_case					=    0.0
         snake_case					=    0.0
         for i in range(len(__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 		a_      (	self      , __snake_case      , __snake_case      , __snake_case      , __snake_case   ):
         for i in range(len(__snake_case   )   ):
              weights[j][i] += alpha * (sample[i] - weights[j][i])
         return weights






def       UpperCAmelCase__						():



     """simple docstring"""






     snake_case					=    [[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

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

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

               # Compute the winning vector
               snake_case					=    self_organizing_map.get_winner(UpperCamelCase_							,UpperCamelCase_    )

               # Update the winning vector
               snake_case					=    self_organizing_map.update(UpperCamelCase_							,UpperCamelCase_							,UpperCamelCase_							,UpperCamelCase_    )

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




