


'''simple docstring'''
from ...configuration_utils import PretrainedConfig
from ...utils import logging


UpperCamelCase__    					=      logging.get_logger(__name__)

UpperCamelCase__    					=      {
    '''facebook/s2t-small-librispeech-asr''': (
        '''https://huggingface.co/facebook/s2t-small-librispeech-asr/resolve/main/config.json'''
    ),
    # See all Speech2Text models at https://huggingface.co/models?filter=speech_to_text
}




class 			lowerCamelCase_   (	__a      ):
      lowerCAmelCase__		     =     'speech_to_text'
      lowerCAmelCase__		     =     ['past_key_values']
      lowerCAmelCase__		     =     {'num_attention_heads': 'encoder_attention_heads', 'hidden_size': 'd_model'}






      def __init__(					self				:    Union[str, Any]						,						_A				:    str=10_000						,						_A				:    Optional[int]=12						,						_A				:    Optional[int]=2_048						,						_A				:    Dict=4						,						_A				:    List[str]=6						,						_A				:    Any=2_048						,						_A				:    Union[str, Any]=4						,						_A				:    str=0.0						,						_A				:    Dict=0.0						,						_A				:    Any=True						,						_A				:    Tuple=True						,						_A				:    str="relu"						,						_A				:    int=256						,						_A				:    List[str]=0.1						,						_A				:    Any=0.0						,						_A				:    Optional[int]=0.0						,						_A				:    List[Any]=0.0_2						,						_A				:    Tuple=2						,						_A				:    Tuple=True						,						_A				:    List[Any]=1						,						_A				:    Optional[Any]=0						,						_A				:    Optional[Any]=2						,						_A				:    Optional[Any]=6_000						,						_A				:    Union[str, Any]=1_024						,						_A				:    List[str]=2						,						_A				:    Optional[Any]=(5, 5)						,						_A				:    int=1_024						,						_A				:    str=80						,						_A				:    List[str]=1						,						**_A				:    List[str]						,						):


          '''simple docstring'''


          UpperCAmelCase__			:		int													=				vocab_size
          UpperCAmelCase__			:		List[Any]													=				d_model
          UpperCAmelCase__			:		int													=				encoder_ffn_dim
          UpperCAmelCase__			:		Union[str, Any]													=				encoder_layers
          UpperCAmelCase__			:		Optional[int]													=				encoder_attention_heads
          UpperCAmelCase__			:		Dict													=				decoder_ffn_dim
          UpperCAmelCase__			:		List[Any]													=				decoder_layers
          UpperCAmelCase__			:		str													=				decoder_attention_heads
          UpperCAmelCase__			:		List[str]													=				dropout
          UpperCAmelCase__			:		Any													=				attention_dropout
          UpperCAmelCase__			:		Dict													=				activation_dropout
          UpperCAmelCase__			:		Any													=				activation_function
          UpperCAmelCase__			:		Optional[Any]													=				init_std
          UpperCAmelCase__			:		Optional[int]													=				encoder_layerdrop
          UpperCAmelCase__			:		List[str]													=				decoder_layerdrop
          UpperCAmelCase__			:		Optional[Any]													=				use_cache
          UpperCAmelCase__			:		Tuple													=				encoder_layers
          UpperCAmelCase__			:		int													=				scale_embedding  # scale factor will be sqrt(d_model) if True
          UpperCAmelCase__			:		List[Any]													=				max_source_positions
          UpperCAmelCase__			:		Optional[int]													=				max_target_positions
          UpperCAmelCase__			:		Optional[Any]													=				num_conv_layers
          UpperCAmelCase__			:		Any													=				list(_A )
          UpperCAmelCase__			:		Any													=				conv_channels
          UpperCAmelCase__			:		int													=				input_feat_per_channel
          UpperCAmelCase__			:		Tuple													=				input_channels

          if len(self.conv_kernel_sizes ) != self.num_conv_layers:
              raise ValueError(
                  '''Configuration for convolutional module is incorrect. '''
                  '''It is required that `len(config.conv_kernel_sizes)` == `config.num_conv_layers` '''
                  f"""but is `len(config.conv_kernel_sizes) = {len(self.conv_kernel_sizes )}`, """
                  f"""`config.num_conv_layers = {self.num_conv_layers}`.""" )

          super().__init__(
              pad_token_id=_A						,						bos_token_id=_A						,						eos_token_id=_A						,						is_encoder_decoder=_A						,						decoder_start_token_id=_A						,						**_A						,						)




'''simple docstring'''
import math




class 			lowerCamelCase_   :






      def lowercase_							(					self				:    Optional[Any]						,						_A				:    list[list[float]]						,						_A				:    list[int] ):


          '''simple docstring'''


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


          '''simple docstring'''


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





def 					a__       (					)    ->	None:
    # Training Examples ( m, n )
    UpperCAmelCase__			:		Optional[Any]													=				[[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

    # training
    UpperCAmelCase__			:		Optional[Any]													=				SelfOrganizingMap()
    UpperCAmelCase__			:		Tuple													=				3
    UpperCAmelCase__			:		Dict													=				0.5

    for _ in range(lowerCAmelCase__						):
        for j in range(len(lowerCAmelCase__						)						):
            # training sample
            UpperCAmelCase__			:		Optional[int]													=				training_samples[j]

            # Compute the winning vector
            UpperCAmelCase__			:		str													=				self_organizing_map.get_winner(lowerCAmelCase__  ,					lowerCAmelCase__						)

            # Update the winning vector
            UpperCAmelCase__			:		int													=				self_organizing_map.update(lowerCAmelCase__  ,					lowerCAmelCase__  ,					lowerCAmelCase__  ,					lowerCAmelCase__						)

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