
import math






class     UpperCAmelCase						:



   def 							_SCREAMING_SNAKE_CASE  (self						:   Optional[Any]       ,		snake_case__						:   list[list[float]]       ,		snake_case__						:   list[int]					)						->      int:


          '''simple docstring'''


          snake_case			:  Optional[Any]     							= 0.0
          snake_case			:  str     							= 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 							_SCREAMING_SNAKE_CASE  (self						:   Optional[int]       ,		snake_case__						:   list[list[int | float]]       ,		snake_case__						:   list[int]       ,		snake_case__						:   int       ,		snake_case__						:   float					)						->      list[list[int | float]]:


          '''simple docstring'''


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



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

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

       # training
       snake_case			:  int     							= SelfOrganizingMap()
       snake_case			:  List[Any]     							= 3
       snake_case			:  Tuple     							= 0.5

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

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

                     # Update the winning vector
                     snake_case			:  Dict     							= self_organizing_map.update(__lowerCamelCase							,   __lowerCamelCase							,   __lowerCamelCase							,   __lowerCamelCase       )

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







from typing import TYPE_CHECKING

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


__lowerCamelCase				=			{
    """configuration_chinese_clip""": [
        """CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """ChineseCLIPConfig""",
        """ChineseCLIPOnnxConfig""",
        """ChineseCLIPTextConfig""",
        """ChineseCLIPVisionConfig""",
    ],
    """processing_chinese_clip""": ["""ChineseCLIPProcessor"""],
}

try:
   if not is_vision_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __lowerCamelCase				=			["""ChineseCLIPFeatureExtractor"""]
   __lowerCamelCase				=			["""ChineseCLIPImageProcessor"""]

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __lowerCamelCase				=			[
       """CHINESE_CLIP_PRETRAINED_MODEL_ARCHIVE_LIST""",
       """ChineseCLIPModel""",
       """ChineseCLIPPreTrainedModel""",
       """ChineseCLIPTextModel""",
       """ChineseCLIPVisionModel""",
   ]

if TYPE_CHECKING:
   from .configuration_chinese_clip import (
       CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
       ChineseCLIPConfig,
       ChineseCLIPOnnxConfig,
       ChineseCLIPTextConfig,
       ChineseCLIPVisionConfig,
   )
   from .processing_chinese_clip import ChineseCLIPProcessor

   try:
      if not is_vision_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .feature_extraction_chinese_clip import ChineseCLIPFeatureExtractor, ChineseCLIPImageProcessor

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_chinese_clip import (
          CHINESE_CLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
          ChineseCLIPModel,
          ChineseCLIPPreTrainedModel,
          ChineseCLIPTextModel,
          ChineseCLIPVisionModel,
      )

else:
   import sys

   __lowerCamelCase				=			_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)





