


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


UpperCAmelCase_ :     Optional[Any]								=      logging.get_logger(__name__)

UpperCAmelCase_ :     List[Any]								=      {
    'facebook/s2t-wav2vec2-large-en-de': (
        'https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/resolve/main/config.json'
    ),
    # See all Speech2Text models at https://huggingface.co/models?filter=speech2text2
}

class 						_lowerCamelCase					(    snake_case_				):




 '''simple docstring'''
 __lowercase				:		Tuple    							=						'''speech_to_text_2'''
 __lowercase				:		Tuple    							=						['''past_key_values''']
 __lowercase				:		Tuple    							=						{'''num_attention_heads''': '''decoder_attention_heads''', '''hidden_size''': '''d_model'''}


 def __init__(      self      ,      __lowercase=10_000      ,      __lowercase=6      ,      __lowercase=2_048      ,      __lowercase=4      ,      __lowercase=0.0      ,      __lowercase=True      ,      __lowercase="relu"      ,      __lowercase=256      ,      __lowercase=0.1      ,      __lowercase=0.0      ,      __lowercase=0.0      ,      __lowercase=0.0_2      ,      __lowercase=2      ,      __lowercase=True      ,      __lowercase=1      ,      __lowercase=0      ,      __lowercase=2      ,      __lowercase=1_024      ,      **__lowercase      ,      ):

  """simple docstring"""







  __A  :		Optional[int]       =			vocab_size
  __A  :		List[str]       =			d_model
  __A  :		List[str]       =			decoder_ffn_dim
  __A  :		Any       =			decoder_layers
  __A  :		List[Any]       =			decoder_attention_heads
  __A  :		str       =			dropout
  __A  :		Dict       =			attention_dropout
  __A  :		Union[str, Any]       =			activation_dropout
  __A  :		List[str]       =			activation_function
  __A  :		Dict       =			init_std
  __A  :		Union[str, Any]       =			decoder_layerdrop
  __A  :		Optional[Any]       =			use_cache
  __A  :		Any       =			decoder_layers
  __A  :		Any       =			scale_embedding  # scale factor will be sqrt(d_model) if True
  __A  :		Optional[Any]       =			max_target_positions

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










'''simple docstring'''
import math

class 						_lowerCamelCase					:




 '''simple docstring'''


 def  snake_case__   (      self      ,      __lowercase      ,      __lowercase						):

  """simple docstring"""







  __A  :		List[str]       =			0.0
  __A  :		Optional[int]       =			0.0
  for i in range(len(__lowercase						)						):
   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  snake_case__   (      self      ,      __lowercase      ,      __lowercase      ,      __lowercase      ,      __lowercase						):

  """simple docstring"""







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


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

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

 # training
 __A  :		Optional[int]       =			SelfOrganizingMap()
 __A  :		int       =			3
 __A  :		Optional[Any]       =			0.5

 for _ in range(UpperCamelCase__			):
  for j in range(len(UpperCamelCase__			)			):
   # training sample
   __A  :		Dict       =			training_samples[j]

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

   # Update the winning vector
   __A  :		Union[str, Any]       =			self_organizing_map.update(UpperCamelCase__,				UpperCamelCase__,				UpperCamelCase__,				UpperCamelCase__			)

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






