


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


__a     =			logging.get_logger(__name__)

__a     =			{
    """uw-madison/mra-base-512-4""": """https://huggingface.co/uw-madison/mra-base-512-4/resolve/main/config.json""",
}






class   __lowercase				(  __snake_case  ):
      UpperCamelCase								=       '''mra'''





      def __init__(		self						:					List[Any]					,       __lowerCamelCase						:					Dict=5_0_2_6_5					,       __lowerCamelCase						:					Tuple=7_6_8					,       __lowerCamelCase						:					int=1_2					,       __lowerCamelCase						:					Optional[int]=1_2					,       __lowerCamelCase						:					str=3_0_7_2					,       __lowerCamelCase						:					str="gelu"					,       __lowerCamelCase						:					Optional[int]=0.1					,       __lowerCamelCase						:					List[Any]=0.1					,       __lowerCamelCase						:					int=5_1_2					,       __lowerCamelCase						:					List[str]=1					,       __lowerCamelCase						:					Union[str, Any]=0.02					,       __lowerCamelCase						:					List[str]=1e-5					,       __lowerCamelCase						:					List[str]="absolute"					,       __lowerCamelCase						:					str=4					,       __lowerCamelCase						:					List[str]="full"					,       __lowerCamelCase						:					Tuple=0					,       __lowerCamelCase						:					Any=0					,       __lowerCamelCase						:					Dict=1					,       __lowerCamelCase						:					Optional[int]=0					,       __lowerCamelCase						:					Union[str, Any]=2					,       **__lowerCamelCase						:					List[Any]					,       )    ->   List[Any]:






         """simple docstring"""







         super().__init__(pad_token_id=__lowerCamelCase					,       bos_token_id=__lowerCamelCase					,       eos_token_id=__lowerCamelCase					,       **__lowerCamelCase       )

         UpperCAmelCase							=     vocab_size
         UpperCAmelCase							=     max_position_embeddings
         UpperCAmelCase							=     hidden_size
         UpperCAmelCase							=     num_hidden_layers
         UpperCAmelCase							=     num_attention_heads
         UpperCAmelCase							=     intermediate_size
         UpperCAmelCase							=     hidden_act
         UpperCAmelCase							=     hidden_dropout_prob
         UpperCAmelCase							=     attention_probs_dropout_prob
         UpperCAmelCase							=     initializer_range
         UpperCAmelCase							=     type_vocab_size
         UpperCAmelCase							=     layer_norm_eps
         UpperCAmelCase							=     position_embedding_type
         UpperCAmelCase							=     block_per_row
         UpperCAmelCase							=     approx_mode
         UpperCAmelCase							=     initial_prior_first_n_blocks
         UpperCAmelCase							=     initial_prior_diagonal_n_blocks







import math






class   __lowercase				:





      def        _lowercase				(		self						:					Union[str, Any]					,       __lowerCamelCase						:					list[list[float]]					,       __lowerCamelCase						:					list[int]       )    ->   int:






         """simple docstring"""







         UpperCAmelCase							=     0.0
         UpperCAmelCase							=     0.0
         for i in range(len(__lowerCamelCase       )       ):
            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						:					List[Any]					,       __lowerCamelCase						:					list[list[int | float]]					,       __lowerCamelCase						:					list[int]					,       __lowerCamelCase						:					int					,       __lowerCamelCase						:					float       )    ->   list[list[int | float]]:






         """simple docstring"""







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

def   _UpperCamelCase				(						)						->None:
   # Training Examples ( m, n )
   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(lowerCAmelCase_   ):
      for j in range(len(lowerCAmelCase_   )   ):
         # training sample
         UpperCAmelCase							=     training_samples[j]

         # Compute the winning vector
         UpperCAmelCase							=     self_organizing_map.get_winner(lowerCAmelCase_  ,						lowerCAmelCase_   )

         # Update the winning vector
         UpperCAmelCase							=     self_organizing_map.update(lowerCAmelCase_  ,						lowerCAmelCase_  ,						lowerCAmelCase_  ,						lowerCAmelCase_   )

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



