
'''simple docstring'''



import functools
import operator

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


_lowercase    =		logging.get_logger(__name__)

_lowercase    =		{
    'microsoft/unispeech-sat-base-100h-libri-ft': (
        'https://huggingface.co/microsoft/unispeech-sat-base-100h-libri-ft/resolve/main/config.json'
    ),
    # See all UniSpeechSat models at https://huggingface.co/models?filter=unispeech_sat
}




class   UpperCAmelCase_					(		lowerCamelCase__			):






	'''simple docstring'''






	_lowercase		:				Union[str, Any]									=       '''unispeech-sat'''




	def __init__( self   ,       _lowercase=32   ,       _lowercase=768   ,       _lowercase=12   ,       _lowercase=12   ,       _lowercase=3_072   ,       _lowercase="gelu"   ,       _lowercase=0.1   ,       _lowercase=0.1   ,       _lowercase=0.1   ,       _lowercase=0.0   ,       _lowercase=0.0   ,       _lowercase=0.1   ,       _lowercase=0.1   ,       _lowercase=0.02   ,       _lowercase=1e-5   ,       _lowercase="group"   ,       _lowercase="gelu"   ,       _lowercase=(512, 512, 512, 512, 512, 512, 512)   ,       _lowercase=(5, 2, 2, 2, 2, 2, 2)   ,       _lowercase=(10, 3, 3, 3, 3, 2, 2)   ,       _lowercase=False   ,       _lowercase=128   ,       _lowercase=16   ,       _lowercase=False   ,       _lowercase=True   ,       _lowercase=0.05   ,       _lowercase=10   ,       _lowercase=2   ,       _lowercase=0.0   ,       _lowercase=10   ,       _lowercase=0   ,       _lowercase=320   ,       _lowercase=2   ,       _lowercase=0.1   ,       _lowercase=100   ,       _lowercase=256   ,       _lowercase=256   ,       _lowercase=0.1   ,       _lowercase="mean"   ,       _lowercase=False   ,       _lowercase=False   ,       _lowercase=256   ,       _lowercase=(512, 512, 512, 512, 1_500)   ,       _lowercase=(5, 3, 3, 1, 1)   ,       _lowercase=(1, 2, 3, 1, 1)   ,       _lowercase=512   ,       _lowercase=0   ,       _lowercase=1   ,       _lowercase=2   ,       _lowercase=504   ,       **_lowercase   ,       ):

							"""simple docstring"""



							super().__init__(**__lowerCamelCase   ,       pad_token_id=__lowerCamelCase   ,       bos_token_id=__lowerCamelCase   ,       eos_token_id=__lowerCamelCase				)
							_lowerCAmelCase  						=			hidden_size
							_lowerCAmelCase  						=			feat_extract_norm
							_lowerCAmelCase  						=			feat_extract_activation
							_lowerCAmelCase  						=			list(__lowerCamelCase				)
							_lowerCAmelCase  						=			list(__lowerCamelCase				)
							_lowerCAmelCase  						=			list(__lowerCamelCase				)
							_lowerCAmelCase  						=			conv_bias
							_lowerCAmelCase  						=			num_conv_pos_embeddings
							_lowerCAmelCase  						=			num_conv_pos_embedding_groups
							_lowerCAmelCase  						=			len(self.conv_dim				)
							_lowerCAmelCase  						=			num_hidden_layers
							_lowerCAmelCase  						=			intermediate_size
							_lowerCAmelCase  						=			hidden_act
							_lowerCAmelCase  						=			num_attention_heads
							_lowerCAmelCase  						=			hidden_dropout
							_lowerCAmelCase  						=			attention_dropout
							_lowerCAmelCase  						=			activation_dropout
							_lowerCAmelCase  						=			feat_proj_dropout
							_lowerCAmelCase  						=			final_dropout
							_lowerCAmelCase  						=			layerdrop
							_lowerCAmelCase  						=			layer_norm_eps
							_lowerCAmelCase  						=			initializer_range
							_lowerCAmelCase  						=			vocab_size
							_lowerCAmelCase  						=			num_clusters
							_lowerCAmelCase  						=			do_stable_layer_norm
							_lowerCAmelCase  						=			use_weighted_layer_sum

							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
							_lowerCAmelCase  						=			apply_spec_augment
							_lowerCAmelCase  						=			mask_time_prob
							_lowerCAmelCase  						=			mask_time_length
							_lowerCAmelCase  						=			mask_time_min_masks
							_lowerCAmelCase  						=			mask_feature_prob
							_lowerCAmelCase  						=			mask_feature_length
							_lowerCAmelCase  						=			mask_feature_min_masks

							# parameters for pretraining with codevector quantized representations
							_lowerCAmelCase  						=			num_codevectors_per_group
							_lowerCAmelCase  						=			num_codevector_groups
							_lowerCAmelCase  						=			contrastive_logits_temperature
							_lowerCAmelCase  						=			feat_quantizer_dropout
							_lowerCAmelCase  						=			num_negatives
							_lowerCAmelCase  						=			codevector_dim
							_lowerCAmelCase  						=			proj_codevector_dim
							_lowerCAmelCase  						=			diversity_loss_weight

							# ctc loss
							_lowerCAmelCase  						=			ctc_loss_reduction
							_lowerCAmelCase  						=			ctc_zero_infinity

							# SequenceClassification-specific parameter. Feel free to ignore for other classes.
							_lowerCAmelCase  						=			classifier_proj_size

							# XVector-specific parameters. Feel free to ignore for other classes.
							_lowerCAmelCase  						=			list(__lowerCamelCase				)
							_lowerCAmelCase  						=			list(__lowerCamelCase				)
							_lowerCAmelCase  						=			list(__lowerCamelCase				)
							_lowerCAmelCase  						=			xvector_output_dim




	@property
	def  _lowercase     ( self				):

							"""simple docstring"""



							return functools.reduce(operator.mul   ,       self.conv_stride   ,       1				)


'''simple docstring'''



from __future__ import annotations

import math


def A				(__lowerCamelCase				:list			,     __lowerCamelCase				:list		):
						if len(__lowerCamelCase		) != 2 or len(a[0]		) != 2 or len(__lowerCamelCase		) != 2 or len(b[0]		) != 2:
												raise Exception("""Matrices are not 2x2"""		)
						_lowerCAmelCase  						=			[
						    [a[0][0] * b[0][0] + a[0][1] * b[1][0], a[0][0] * b[0][1] + a[0][1] * b[1][1]],
						    [a[1][0] * b[0][0] + a[1][1] * b[1][0], a[1][0] * b[0][1] + a[1][1] * b[1][1]],
						]
						return new_matrix


def A				(__lowerCamelCase				:list			,     __lowerCamelCase				:list		):
						return [
						    [matrix_a[row][col] + matrix_b[row][col] for col in range(len(matrix_a[row]		)		)]
						    for row in range(len(__lowerCamelCase		)		)
						]


def A				(__lowerCamelCase				:list			,     __lowerCamelCase				:list		):
						return [
						    [matrix_a[row][col] - matrix_b[row][col] for col in range(len(matrix_a[row]		)		)]
						    for row in range(len(__lowerCamelCase		)		)
						]


def A				(__lowerCamelCase				:list		):
						if len(__lowerCamelCase		) % 2 != 0 or len(a[0]		) % 2 != 0:
												raise Exception("""Odd matrices are not supported!"""		)

						_lowerCAmelCase  						=			len(__lowerCamelCase		)
						_lowerCAmelCase  						=			matrix_length // 2

						_lowerCAmelCase  						=			[[a[i][j] for j in range(__lowerCamelCase			,     __lowerCamelCase		)] for i in range(__lowerCamelCase		)]
						_lowerCAmelCase  						=			[
						    [a[i][j] for j in range(__lowerCamelCase			,     __lowerCamelCase		)] for i in range(__lowerCamelCase			,     __lowerCamelCase		)
						]

						_lowerCAmelCase  						=			[[a[i][j] for j in range(__lowerCamelCase		)] for i in range(__lowerCamelCase		)]
						_lowerCAmelCase  						=			[[a[i][j] for j in range(__lowerCamelCase		)] for i in range(__lowerCamelCase			,     __lowerCamelCase		)]

						return top_left, top_right, bot_left, bot_right


def A				(__lowerCamelCase				:list		):
						return len(__lowerCamelCase		), len(matrix[0]		)


def A				(__lowerCamelCase				:list		):
						print("""\n""".join(str(__lowerCamelCase		) for line in matrix		)		)


def A				(__lowerCamelCase				:list			,     __lowerCamelCase				:list		):
						if matrix_dimensions(__lowerCamelCase		) == (2, 2):
												return default_matrix_multiplication(__lowerCamelCase			,     __lowerCamelCase		)

						_lowerCAmelCase						,   _lowerCAmelCase						,   _lowerCAmelCase						,   _lowerCAmelCase  						=			split_matrix(__lowerCamelCase		)
						_lowerCAmelCase						,   _lowerCAmelCase						,   _lowerCAmelCase						,   _lowerCAmelCase  						=			split_matrix(__lowerCamelCase		)

						_lowerCAmelCase  						=			actual_strassen(__lowerCamelCase			,     matrix_subtraction(__lowerCamelCase			,     __lowerCamelCase		)		)
						_lowerCAmelCase  						=			actual_strassen(matrix_addition(__lowerCamelCase			,     __lowerCamelCase		)			,     __lowerCamelCase		)
						_lowerCAmelCase  						=			actual_strassen(matrix_addition(__lowerCamelCase			,     __lowerCamelCase		)			,     __lowerCamelCase		)
						_lowerCAmelCase  						=			actual_strassen(__lowerCamelCase			,     matrix_subtraction(__lowerCamelCase			,     __lowerCamelCase		)		)
						_lowerCAmelCase  						=			actual_strassen(matrix_addition(__lowerCamelCase			,     __lowerCamelCase		)			,     matrix_addition(__lowerCamelCase			,     __lowerCamelCase		)		)
						_lowerCAmelCase  						=			actual_strassen(matrix_subtraction(__lowerCamelCase			,     __lowerCamelCase		)			,     matrix_addition(__lowerCamelCase			,     __lowerCamelCase		)		)
						_lowerCAmelCase  						=			actual_strassen(matrix_subtraction(__lowerCamelCase			,     __lowerCamelCase		)			,     matrix_addition(__lowerCamelCase			,     __lowerCamelCase		)		)

						_lowerCAmelCase  						=			matrix_addition(matrix_subtraction(matrix_addition(__lowerCamelCase			,     __lowerCamelCase		)			,     __lowerCamelCase		)			,     __lowerCamelCase		)
						_lowerCAmelCase  						=			matrix_addition(__lowerCamelCase			,     __lowerCamelCase		)
						_lowerCAmelCase  						=			matrix_addition(__lowerCamelCase			,     __lowerCamelCase		)
						_lowerCAmelCase  						=			matrix_subtraction(matrix_subtraction(matrix_addition(__lowerCamelCase			,     __lowerCamelCase		)			,     __lowerCamelCase		)			,     __lowerCamelCase		)

						# construct the new matrix from our 4 quadrants
						_lowerCAmelCase  						=			[]
						for i in range(len(__lowerCamelCase		)		):
												new_matrix.append(top_left[i] + top_right[i]		)
						for i in range(len(__lowerCamelCase		)		):
												new_matrix.append(bot_left[i] + bot_right[i]		)
						return new_matrix


def A				(__lowerCamelCase				:list			,     __lowerCamelCase				:list		):
						if matrix_dimensions(__lowerCamelCase		)[1] != matrix_dimensions(__lowerCamelCase		)[0]:
												_lowerCAmelCase  						=			(
												    """Unable to multiply these matrices, please check the dimensions.\n"""
												    f'Matrix A: {matrixa}\n'
												    f'Matrix B: {matrixa}'
												)
												raise Exception(__lowerCamelCase		)
						_lowerCAmelCase  						=			matrix_dimensions(__lowerCamelCase		)
						_lowerCAmelCase  						=			matrix_dimensions(__lowerCamelCase		)

						if dimensiona[0] == dimensiona[1] and dimensiona[0] == dimensiona[1]:
												return [matrixa, matrixa]

						_lowerCAmelCase  						=			max(*__lowerCamelCase			,     *__lowerCamelCase		)
						_lowerCAmelCase  						=			int(math.pow(2			,     math.ceil(math.loga(__lowerCamelCase		)		)		)		)
						_lowerCAmelCase  						=			matrixa
						_lowerCAmelCase  						=			matrixa

						# Adding zeros to the matrices so that the arrays dimensions are the same and also
						# power of 2
						for i in range(0			,     __lowerCamelCase		):
												if i < dimensiona[0]:
																		for _ in range(dimensiona[1]			,     __lowerCamelCase		):
																								new_matrixa[i].append(0		)
												else:
																		new_matrixa.append([0] * maxim		)
												if i < dimensiona[0]:
																		for _ in range(dimensiona[1]			,     __lowerCamelCase		):
																								new_matrixa[i].append(0		)
												else:
																		new_matrixa.append([0] * maxim		)

						_lowerCAmelCase  						=			actual_strassen(__lowerCamelCase			,     __lowerCamelCase		)

						# Removing the additional zeros
						for i in range(0			,     __lowerCamelCase		):
												if i < dimensiona[0]:
																		for _ in range(dimensiona[1]			,     __lowerCamelCase		):
																								final_matrix[i].pop()
												else:
																		final_matrix.pop()
						return final_matrix


if __name__ == "__main__":
						_lowercase    =		[
						    [2, 3, 4, 5],
						    [6, 4, 3, 1],
						    [2, 3, 6, 7],
						    [3, 1, 2, 4],
						    [2, 3, 4, 5],
						    [6, 4, 3, 1],
						    [2, 3, 6, 7],
						    [3, 1, 2, 4],
						    [2, 3, 4, 5],
						    [6, 2, 3, 1],
						]
						_lowercase    =		[[0, 2, 1, 1], [16, 2, 3, 3], [2, 2, 7, 7], [13, 11, 22, 4]]
						print(strassen(matrixa, matrixa))
