


from ...configuration_utils import PretrainedConfig
from ...utils import logging


_SCREAMING_SNAKE_CASE      :			str      				=   logging.get_logger(__name__)

_SCREAMING_SNAKE_CASE      :			List[str]      				=   {
    "microsoft/swinv2-tiny-patch4-window8-256": (
        "https://huggingface.co/microsoft/swinv2-tiny-patch4-window8-256/resolve/main/config.json"
    ),
}

class   A__ (   snake_case__     ):







    """simple docstring"""

    __magic_name__        =		'swinv2'

    __magic_name__        =		{
        'num_attention_heads': 'num_heads',
        'num_hidden_layers': 'num_layers',
    }
    def __init__(	self      , __snake_case=2_2_4      , __snake_case=4      , __snake_case=3      , __snake_case=9_6      , __snake_case=[2, 2, 6, 2]      , __snake_case=[3, 6, 1_2, 2_4]      , __snake_case=7      , __snake_case=4.0      , __snake_case=True      , __snake_case=0.0      , __snake_case=0.0      , __snake_case=0.1      , __snake_case="gelu"      , __snake_case=False      , __snake_case=0.02      , __snake_case=1E-5      , __snake_case=3_2      , **__snake_case      , ):
         super().__init__(**__snake_case   )

         snake_case					=    image_size
         snake_case					=    patch_size
         snake_case					=    num_channels
         snake_case					=    embed_dim
         snake_case					=    depths
         snake_case					=    len(__snake_case   )
         snake_case					=    num_heads
         snake_case					=    window_size
         snake_case					=    mlp_ratio
         snake_case					=    qkv_bias
         snake_case					=    hidden_dropout_prob
         snake_case					=    attention_probs_dropout_prob
         snake_case					=    drop_path_rate
         snake_case					=    hidden_act
         snake_case					=    use_absolute_embeddings
         snake_case					=    layer_norm_eps
         snake_case					=    initializer_range
         snake_case					=    encoder_stride
         # we set the hidden_size attribute in order to make Swinv2 work with VisionEncoderDecoderModel
         # this indicates the channel dimension after the last stage of the model
         snake_case					=    int(embed_dim * 2 ** (len(__snake_case   ) - 1)   )
         snake_case					=    (0, 0, 0, 0)








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()




