'''simple docstring'''

import functools
import operator

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


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

lowerCAmelCase_			:			Any    	=   {
    "facebook/hubert-base-ls960": "https://huggingface.co/facebook/hubert-base-ls960/resolve/main/config.json",
    # See all Hubert models at https://huggingface.co/models?filter=hubert
}





class 				lowercase    (    __lowerCamelCase			):
   lowerCamelCase_            ='hubert'


   def __init__( self					:						Optional[Any] ,		__lowerCAmelCase					:						Union[str, Any]=32 ,		__lowerCAmelCase					:						List[str]=768 ,		__lowerCAmelCase					:						int=12 ,		__lowerCAmelCase					:						Optional[int]=12 ,		__lowerCAmelCase					:						Tuple=3072 ,		__lowerCAmelCase					:						Optional[int]="gelu" ,		__lowerCAmelCase					:						str=0.1 ,		__lowerCAmelCase					:						int=0.1 ,		__lowerCAmelCase					:						str=0.1 ,		__lowerCAmelCase					:						Optional[int]=True ,		__lowerCAmelCase					:						Optional[Any]=0.0 ,		__lowerCAmelCase					:						int=0.1 ,		__lowerCAmelCase					:						Tuple=0.1 ,		__lowerCAmelCase					:						str=0.02 ,		__lowerCAmelCase					:						int=1e-5 ,		__lowerCAmelCase					:						Tuple="group" ,		__lowerCAmelCase					:						Optional[Any]="gelu" ,		__lowerCAmelCase					:						int=(512, 512, 512, 512, 512, 512, 512) ,		__lowerCAmelCase					:						Optional[Any]=(5, 2, 2, 2, 2, 2, 2) ,		__lowerCAmelCase					:						Optional[int]=(10, 3, 3, 3, 3, 2, 2) ,		__lowerCAmelCase					:						List[Any]=False ,		__lowerCAmelCase					:						Dict=128 ,		__lowerCAmelCase					:						Union[str, Any]=16 ,		__lowerCAmelCase					:						List[str]=False ,		__lowerCAmelCase					:						Tuple=True ,		__lowerCAmelCase					:						int=0.05 ,		__lowerCAmelCase					:						List[str]=10 ,		__lowerCAmelCase					:						Tuple=2 ,		__lowerCAmelCase					:						Union[str, Any]=0.0 ,		__lowerCAmelCase					:						int=10 ,		__lowerCAmelCase					:						Union[str, Any]=0 ,		__lowerCAmelCase					:						List[str]="sum" ,		__lowerCAmelCase					:						Any=False ,		__lowerCAmelCase					:						Any=False ,		__lowerCAmelCase					:						Optional[int]=256 ,		__lowerCAmelCase					:						Union[str, Any]=0 ,		__lowerCAmelCase					:						Union[str, Any]=1 ,		__lowerCAmelCase					:						List[Any]=2 ,		**__lowerCAmelCase					:						Dict ,		)   ->       Optional[int]:
         super().__init__(**__lowerCAmelCase ,		pad_token_id=__lowerCAmelCase ,		bos_token_id=__lowerCAmelCase ,		eos_token_id=__lowerCAmelCase)
         lowercase_     			=   hidden_size
         lowercase_     			=   feat_extract_norm
         lowercase_     			=   feat_extract_activation
         lowercase_     			=   list(__lowerCAmelCase)
         lowercase_     			=   list(__lowerCAmelCase)
         lowercase_     			=   list(__lowerCAmelCase)
         lowercase_     			=   conv_bias
         lowercase_     			=   num_conv_pos_embeddings
         lowercase_     			=   num_conv_pos_embedding_groups
         lowercase_     			=   len(self.conv_dim)
         lowercase_     			=   num_hidden_layers
         lowercase_     			=   intermediate_size
         lowercase_     			=   hidden_act
         lowercase_     			=   num_attention_heads
         lowercase_     			=   hidden_dropout
         lowercase_     			=   attention_dropout
         lowercase_     			=   activation_dropout
         lowercase_     			=   feat_proj_layer_norm
         lowercase_     			=   feat_proj_dropout
         lowercase_     			=   final_dropout
         lowercase_     			=   layerdrop
         lowercase_     			=   layer_norm_eps
         lowercase_     			=   initializer_range
         lowercase_     			=   vocab_size
         lowercase_     			=   do_stable_layer_norm
         lowercase_     			=   use_weighted_layer_sum
         lowercase_     			=   classifier_proj_size

         if (
             (len(self.conv_stride) != self.num_feat_extract_layers)
             or (len(self.conv_kernel) != self.num_feat_extract_layers)
             or (len(self.conv_dim) != self.num_feat_extract_layers)
         ):
               raise ValueError(
                   "Configuration for convolutional layers is incorrect. It is required that `len(config.conv_dim)` =="
                   " `len(config.conv_stride)` == `len(config.conv_kernel)`, but is `len(config.conv_dim) ="
                   F' {len(self.conv_dim)}`, `len(config.conv_stride) = {len(self.conv_stride)}`,'
                   F' `len(config.conv_kernel) = {len(self.conv_kernel)}`.')

         # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
         lowercase_     			=   apply_spec_augment
         lowercase_     			=   mask_time_prob
         lowercase_     			=   mask_time_length
         lowercase_     			=   mask_time_min_masks
         lowercase_     			=   mask_feature_prob
         lowercase_     			=   mask_feature_length
         lowercase_     			=   mask_feature_min_masks

         # ctc loss
         lowercase_     			=   ctc_loss_reduction
         lowercase_     			=   ctc_zero_infinity


   @property
   def __UpperCAmelCase							( self					:						List[Any])   ->       Optional[int]:
         return functools.reduce(operator.mul ,		self.conv_stride ,		1)







'''simple docstring'''

import timeit





class 				lowercase    :


   def __init__( self					:						Dict ,		__lowerCAmelCase					:						Any)   ->       Optional[int]:
         if isinstance(__lowerCAmelCase ,		__lowerCAmelCase):  # Initializes a matrix identical to the one provided.
               lowercase_     			=   arg
               lowercase_     			=   len(__lowerCAmelCase)
         else:  # Initializes a square matrix of the given size and set values to zero.
               lowercase_     			=   arg
               lowercase_     			=   [[0 for _ in range(self.n)] for _ in range(self.n)]


   def __mul__( self					:						int ,		__lowerCAmelCase					:						List[str])   ->       Union[str, Any]:
         lowercase_     			=   Matrix(self.n)
         for i in range(self.n):
               for j in range(self.n):
                     for k in range(self.n):
                           matrix.t[i][j] += self.t[i][k] * b.t[k][j]
         return matrix




def __a			(						__lowerCamelCase      :    List[str]			,		__lowerCamelCase      :    Dict					)						->				Optional[Any]:
      '''simple docstring'''


      lowercase_     			=   Matrix([[1, 0], [0, 1]]					)
      while b > 0:
            if b & 1:
                  matrix *= a
            a *= a
            b >>= 1
      return matrix


def __a			(						__lowerCamelCase      :    Tuple			,		__lowerCamelCase      :    Tuple			,		__lowerCamelCase      :    List[Any]					)						->				Dict:
      '''simple docstring'''


      if n == 1:
            return fa
      elif n == 2:
            return fa
      lowercase_     			=   Matrix([[1, 1], [1, 0]]					)
      lowercase_     			=   modular_exponentiation(__lowerCamelCase			,		n - 2					)
      return fa * matrix.t[0][0] + fa * matrix.t[0][1]


def __a			(						__lowerCamelCase      :    List[Any]			,		__lowerCamelCase      :    Union[str, Any]			,		__lowerCamelCase      :    List[str]					)						->				Optional[Any]:
      '''simple docstring'''


      if n == 1:
            return fa
      elif n == 2:
            return fa

      lowercase_     			=   fa
      lowercase_     			=   fa
      n -= 2

      while n > 0:
            lowercase_			,				lowercase_     			=   fn_a + fn_a, fn_a
            n -= 1

      return fn_a


def __a			(						)						->				str:
      '''simple docstring'''


      lowercase_     			=   "\nfrom random import randint\nfrom __main__ import fibonacci_with_matrix_exponentiation\n"
      lowercase_     			=   "fibonacci_with_matrix_exponentiation(randint(1,70000), 1, 1)"
      lowercase_     			=   timeit.timeit(setup=__lowerCamelCase			,		stmt=__lowerCamelCase			,		number=100					)
      print("With matrix exponentiation the average execution time is "			,		exec_time / 100					)
      return exec_time


def __a			(						)						->				Optional[Any]:
      '''simple docstring'''


      lowercase_     			=   "\nfrom random import randint\nfrom __main__ import simple_fibonacci\n"
      lowercase_     			=   "simple_fibonacci(randint(1,70000), 1, 1)"
      lowercase_     			=   timeit.timeit(setup=__lowerCamelCase			,		stmt=__lowerCamelCase			,		number=100					)
      print(
          "Without matrix exponentiation the average execution time is "			,		exec_time / 100					)
      return exec_time


def __a			(						)						->				Tuple:
      '''simple docstring'''


      matrix_exponentiation_time()
      simple_fibonacci_time()


if __name__ == "__main__":
       main()






