






from __future__ import annotations

import math
import random
from collections.abc import Collection
from typing import overload





class 			__a  :







 def __init__(		self					:   Any							,   SCREAMING_SNAKE_CASE					:   Collection[float] | None = None						):


      '''simple docstring'''






      if components is None:
           UpperCamelCase__			:   int       				=  []
      UpperCamelCase__			:   List[str]       				=  list(SCREAMING_SNAKE_CASE						)







 def __len__(		self					:   Any						):


      '''simple docstring'''






      return len(self.__components						)







 def __str__(		self					:   List[str]						):


      '''simple docstring'''






      return "(" + ",".join(map(SCREAMING_SNAKE_CASE							,   self.__components						)						) + ")"







 def __add__(		self					:   Union[str, Any]							,   SCREAMING_SNAKE_CASE					:   Vector						):


      '''simple docstring'''






      UpperCamelCase__			:   int       				=  len(self						)
      if size == len(SCREAMING_SNAKE_CASE						):
           UpperCamelCase__			:   Union[str, Any]       				=  [self.__components[i] + other.component(SCREAMING_SNAKE_CASE						) for i in range(SCREAMING_SNAKE_CASE						)]
           return Vector(SCREAMING_SNAKE_CASE						)
      else:
           raise Exception("must have the same size"						)







 def __sub__(		self					:   int							,   SCREAMING_SNAKE_CASE					:   Vector						):


      '''simple docstring'''






      UpperCamelCase__			:   Optional[int]       				=  len(self						)
      if size == len(SCREAMING_SNAKE_CASE						):
           UpperCamelCase__			:   Dict       				=  [self.__components[i] - other.component(SCREAMING_SNAKE_CASE						) for i in range(SCREAMING_SNAKE_CASE						)]
           return Vector(SCREAMING_SNAKE_CASE						)
      else:  # error case
           raise Exception("must have the same size"						)







 @overload
 def __mul__(		self					:   int							,   SCREAMING_SNAKE_CASE					:   float						):


      '''simple docstring'''






      ...







 @overload
 def __mul__(		self					:   List[Any]							,   SCREAMING_SNAKE_CASE					:   Vector						):


      '''simple docstring'''






      ...







 def __mul__(		self					:   str							,   SCREAMING_SNAKE_CASE					:   float | Vector						):


      '''simple docstring'''






      if isinstance(SCREAMING_SNAKE_CASE							,   (float, int)						):
           UpperCamelCase__			:   Any       				=  [c * other for c in self.__components]
           return Vector(SCREAMING_SNAKE_CASE						)
      elif isinstance(SCREAMING_SNAKE_CASE							,   SCREAMING_SNAKE_CASE						) and len(self						) == len(SCREAMING_SNAKE_CASE						):
           UpperCamelCase__			:   Dict       				=  len(self						)
           UpperCamelCase__			:   Union[str, Any]       				=  [self.__components[i] * other.component(SCREAMING_SNAKE_CASE						) for i in range(SCREAMING_SNAKE_CASE						)]
           return sum(SCREAMING_SNAKE_CASE						)
      else:  # error case
           raise Exception("invalid operand!"						)







 def 					__lowercase					(		self					:   Union[str, Any]						):


      '''simple docstring'''






      return Vector(self.__components						)







 def 					__lowercase					(		self					:   Tuple							,   SCREAMING_SNAKE_CASE					:   int						):


      '''simple docstring'''






      if isinstance(SCREAMING_SNAKE_CASE							,   SCREAMING_SNAKE_CASE						) and -len(self.__components						) <= i < len(self.__components						):
           return self.__components[i]
      else:
           raise Exception("index out of range"						)







 def 					__lowercase					(		self					:   Union[str, Any]							,   SCREAMING_SNAKE_CASE					:   int							,   SCREAMING_SNAKE_CASE					:   float						):


      '''simple docstring'''






      assert -len(self.__components						) <= pos < len(self.__components						)
      UpperCamelCase__			:   Optional[Any]       				=  value







 def 					__lowercase					(		self					:   Optional[Any]						):


      '''simple docstring'''






      if len(self.__components						) == 0:
           raise Exception("Vector is empty"						)
      UpperCamelCase__			:   List[Any]       				=  [c**2 for c in self.__components]
      return math.sqrt(sum(SCREAMING_SNAKE_CASE						)						)







 def 					__lowercase					(		self					:   Tuple							,   SCREAMING_SNAKE_CASE					:   Vector							,   SCREAMING_SNAKE_CASE					:   bool = False						):


      '''simple docstring'''






      UpperCamelCase__			:   List[Any]       				=  self * other
      UpperCamelCase__			:   List[Any]       				=  self.euclidean_length() * other.euclidean_length()
      if deg:
           return math.degrees(math.acos(num / den						)						)
      else:
           return math.acos(num / den						)







def 		SCREAMING_SNAKE_CASE							(					__lowerCAmelCase			) ->	Vector:
     assert isinstance(__lowerCAmelCase					,    __lowerCAmelCase			)
     return Vector([0] * dimension			)







def 		SCREAMING_SNAKE_CASE							(					__lowerCAmelCase					,    __lowerCAmelCase			) ->	Vector:
     assert isinstance(__lowerCAmelCase					,    __lowerCAmelCase			) and (isinstance(__lowerCAmelCase					,    __lowerCAmelCase			))
     UpperCamelCase__			:   str       				=  [0] * dimension
     UpperCamelCase__			:   Union[str, Any]       				=  1
     return Vector(__lowerCAmelCase			)







def 		SCREAMING_SNAKE_CASE							(					__lowerCAmelCase					,    __lowerCAmelCase					,    __lowerCAmelCase			) ->	Vector:
     assert (
         isinstance(__lowerCAmelCase					,    __lowerCAmelCase			)
         and isinstance(__lowerCAmelCase					,    __lowerCAmelCase			)
         and (isinstance(__lowerCAmelCase					,    (int, float)			))
     )
     return x * scalar + y







def 		SCREAMING_SNAKE_CASE							(					__lowerCAmelCase					,    __lowerCAmelCase					,    __lowerCAmelCase			) ->	Vector:
     random.seed(__lowerCAmelCase			)
     UpperCamelCase__			:   int       				=  [random.randint(__lowerCAmelCase					,    __lowerCAmelCase			) for _ in range(__lowerCAmelCase			)]
     return Vector(__lowerCAmelCase			)





class 			__a  :







 def __init__(		self					:   Optional[int]							,   SCREAMING_SNAKE_CASE					:   list[list[float]]							,   SCREAMING_SNAKE_CASE					:   int							,   SCREAMING_SNAKE_CASE					:   int						):


      '''simple docstring'''






      UpperCamelCase__			:   Dict       				=  matrix
      UpperCamelCase__			:   int       				=  w
      UpperCamelCase__			:   Optional[Any]       				=  h







 def __str__(		self					:   Union[str, Any]						):


      '''simple docstring'''






      UpperCamelCase__			:   List[str]       				=  ""
      for i in range(self.__height						):
           ans += "|"
           for j in range(self.__width						):
                if j < self.__width - 1:
                     ans += str(self.__matrix[i][j]						) + ","
                else:
                     ans += str(self.__matrix[i][j]						) + "|\n"
      return ans







 def __add__(		self					:   Optional[int]							,   SCREAMING_SNAKE_CASE					:   Matrix						):


      '''simple docstring'''






      if self.__width == other.width() and self.__height == other.height():
           UpperCamelCase__			:   Union[str, Any]       				=  []
           for i in range(self.__height						):
                UpperCamelCase__			:   List[str]       				=  [
                    self.__matrix[i][j] + other.component(SCREAMING_SNAKE_CASE							,   SCREAMING_SNAKE_CASE						)
                    for j in range(self.__width						)
                ]
                matrix.append(SCREAMING_SNAKE_CASE						)
           return Matrix(SCREAMING_SNAKE_CASE							,   self.__width							,   self.__height						)
      else:
           raise Exception("matrix must have the same dimension!"						)







 def __sub__(		self					:   str							,   SCREAMING_SNAKE_CASE					:   Matrix						):


      '''simple docstring'''






      if self.__width == other.width() and self.__height == other.height():
           UpperCamelCase__			:   Optional[int]       				=  []
           for i in range(self.__height						):
                UpperCamelCase__			:   List[str]       				=  [
                    self.__matrix[i][j] - other.component(SCREAMING_SNAKE_CASE							,   SCREAMING_SNAKE_CASE						)
                    for j in range(self.__width						)
                ]
                matrix.append(SCREAMING_SNAKE_CASE						)
           return Matrix(SCREAMING_SNAKE_CASE							,   self.__width							,   self.__height						)
      else:
           raise Exception("matrices must have the same dimension!"						)







 @overload
 def __mul__(		self					:   Optional[Any]							,   SCREAMING_SNAKE_CASE					:   float						):


      '''simple docstring'''






      ...







 @overload
 def __mul__(		self					:   List[str]							,   SCREAMING_SNAKE_CASE					:   Vector						):


      '''simple docstring'''






      ...







 def __mul__(		self					:   Optional[Any]							,   SCREAMING_SNAKE_CASE					:   float | Vector						):


      '''simple docstring'''






      if isinstance(SCREAMING_SNAKE_CASE							,   SCREAMING_SNAKE_CASE						):  # matrix-vector
           if len(SCREAMING_SNAKE_CASE						) == self.__width:
                UpperCamelCase__			:   int       				=  zero_vector(self.__height						)
                for i in range(self.__height						):
                     UpperCamelCase__			:   List[Any]       				=  [
                         self.__matrix[i][j] * other.component(SCREAMING_SNAKE_CASE						)
                         for j in range(self.__width						)
                     ]
                     ans.change_component(SCREAMING_SNAKE_CASE							,   sum(SCREAMING_SNAKE_CASE						)						)
                return ans
           else:
                raise Exception(
                    "vector must have the same size as the "
                    "number of columns of the matrix!"						)
      elif isinstance(SCREAMING_SNAKE_CASE							,   (int, float)						):  # matrix-scalar
           UpperCamelCase__			:   Any       				=  [
               [self.__matrix[i][j] * other for j in range(self.__width						)]
               for i in range(self.__height						)
           ]
           return Matrix(SCREAMING_SNAKE_CASE							,   self.__width							,   self.__height						)
      return None







 def 					__lowercase					(		self					:   List[str]						):


      '''simple docstring'''






      return self.__height







 def 					__lowercase					(		self					:   List[Any]						):


      '''simple docstring'''






      return self.__width







 def 					__lowercase					(		self					:   Any							,   SCREAMING_SNAKE_CASE					:   int							,   SCREAMING_SNAKE_CASE					:   int						):


      '''simple docstring'''






      if 0 <= x < self.__height and 0 <= y < self.__width:
           return self.__matrix[x][y]
      else:
           raise Exception("change_component: indices out of bounds"						)







 def 					__lowercase					(		self					:   str							,   SCREAMING_SNAKE_CASE					:   int							,   SCREAMING_SNAKE_CASE					:   int							,   SCREAMING_SNAKE_CASE					:   float						):


      '''simple docstring'''






      if 0 <= x < self.__height and 0 <= y < self.__width:
           UpperCamelCase__			:   Tuple       				=  value
      else:
           raise Exception("change_component: indices out of bounds"						)







 def 					__lowercase					(		self					:   Any							,   SCREAMING_SNAKE_CASE					:   int							,   SCREAMING_SNAKE_CASE					:   int						):


      '''simple docstring'''






      if self.__height != self.__width:
           raise Exception("Matrix is not square"						)
      UpperCamelCase__			:   Dict       				=  self.__matrix[:x] + self.__matrix[x + 1 :]
      for i in range(len(SCREAMING_SNAKE_CASE						)						):
           UpperCamelCase__			:   Optional[Any]       				=  minor[i][:y] + minor[i][y + 1 :]
      return Matrix(SCREAMING_SNAKE_CASE							,   self.__width - 1							,   self.__height - 1						).determinant()







 def 					__lowercase					(		self					:   Optional[int]							,   SCREAMING_SNAKE_CASE					:   int							,   SCREAMING_SNAKE_CASE					:   int						):


      '''simple docstring'''






      if self.__height != self.__width:
           raise Exception("Matrix is not square"						)
      if 0 <= x < self.__height and 0 <= y < self.__width:
           return (-1) ** (x + y) * self.minor(SCREAMING_SNAKE_CASE							,   SCREAMING_SNAKE_CASE						)
      else:
           raise Exception("Indices out of bounds"						)







 def 					__lowercase					(		self					:   Any						):


      '''simple docstring'''






      if self.__height != self.__width:
           raise Exception("Matrix is not square"						)
      if self.__height < 1:
           raise Exception("Matrix has no element"						)
      elif self.__height == 1:
           return self.__matrix[0][0]
      elif self.__height == 2:
           return (
               self.__matrix[0][0] * self.__matrix[1][1]
               - self.__matrix[0][1] * self.__matrix[1][0]
           )
      else:
           UpperCamelCase__			:   Tuple       				=  [
               self.__matrix[0][y] * self.cofactor(0							,   SCREAMING_SNAKE_CASE						) for y in range(self.__width						)
           ]
           return sum(SCREAMING_SNAKE_CASE						)







def 		SCREAMING_SNAKE_CASE							(					__lowerCAmelCase			) ->	Matrix:
     UpperCamelCase__			:   list[list[float]]       				=  [[0] * n for _ in range(__lowerCAmelCase			)]
     return Matrix(__lowerCAmelCase					,    __lowerCAmelCase					,    __lowerCAmelCase			)







def 		SCREAMING_SNAKE_CASE							(					__lowerCAmelCase					,    __lowerCAmelCase					,    __lowerCAmelCase					,    __lowerCAmelCase			) ->	Matrix:
     random.seed(__lowerCAmelCase			)
     UpperCamelCase__			:   list[list[float]]       				=  [
         [random.randint(__lowerCAmelCase					,    __lowerCAmelCase			) for _ in range(__lowerCAmelCase			)] for _ in range(__lowerCAmelCase			)
     ]
     return Matrix(__lowerCAmelCase					,    __lowerCAmelCase					,    __lowerCAmelCase			)







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


lowerCamelCase	:							Optional[int]				=logging.get_logger(__name__)

lowerCamelCase	:							Dict				={
    '''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 			__a  (    A__       ):
 _lowerCAmelCase       :       Tuple        = '''speech_to_text_2'''
 _lowerCAmelCase       :       Dict        = ['''past_key_values''']
 _lowerCAmelCase       :       Any        = {'''num_attention_heads''': '''decoder_attention_heads''', '''hidden_size''': '''d_model'''}







 def __init__(		self					:   List[str]							,   SCREAMING_SNAKE_CASE					:   Union[str, Any]=1_00_00							,   SCREAMING_SNAKE_CASE					:   List[Any]=6							,   SCREAMING_SNAKE_CASE					:   List[Any]=20_48							,   SCREAMING_SNAKE_CASE					:   Dict=4							,   SCREAMING_SNAKE_CASE					:   List[Any]=0.0							,   SCREAMING_SNAKE_CASE					:   Optional[int]=True							,   SCREAMING_SNAKE_CASE					:   List[Any]="relu"							,   SCREAMING_SNAKE_CASE					:   Tuple=2_56							,   SCREAMING_SNAKE_CASE					:   List[str]=0.1							,   SCREAMING_SNAKE_CASE					:   Tuple=0.0							,   SCREAMING_SNAKE_CASE					:   Any=0.0							,   SCREAMING_SNAKE_CASE					:   int=0.0_2							,   SCREAMING_SNAKE_CASE					:   Dict=2							,   SCREAMING_SNAKE_CASE					:   List[str]=True							,   SCREAMING_SNAKE_CASE					:   Any=1							,   SCREAMING_SNAKE_CASE					:   List[Any]=0							,   SCREAMING_SNAKE_CASE					:   Any=2							,   SCREAMING_SNAKE_CASE					:   str=10_24							,   **SCREAMING_SNAKE_CASE					:   int							,   ):


      '''simple docstring'''






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

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