




"""simple docstring"""
from __future__ import annotations

import math





def 						UpperCAmelCase				(			A__:    list							,				A__:    list     )  ->     list:
			if len(A__     ) != 2 or len(a[0]     ) != 2 or len(A__     ) != 2 or len(b[0]     ) != 2:
						raise Exception('Matrices are not 2x2'     )
			__lowerCamelCase					:	int	       =				[
			    [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 						UpperCAmelCase				(			A__:    list							,				A__:    list     )  ->     Tuple:
			return [
			    [matrix_a[row][col] + matrix_b[row][col] for col in range(len(matrix_a[row]     )     )]
			    for row in range(len(A__     )     )
			]





def 						UpperCAmelCase				(			A__:    list							,				A__:    list     )  ->     Optional[Any]:
			return [
			    [matrix_a[row][col] - matrix_b[row][col] for col in range(len(matrix_a[row]     )     )]
			    for row in range(len(A__     )     )
			]





def 						UpperCAmelCase				(			A__:    list     )  ->     tuple[list, list, list, list]:
			if len(A__     ) % 2 != 0 or len(a[0]     ) % 2 != 0:
						raise Exception('Odd matrices are not supported!'     )

			__lowerCamelCase					:	Optional[Any]	       =				len(A__     )
			__lowerCamelCase					:	str	       =				matrix_length // 2

			__lowerCamelCase					:	Union[str, Any]	       =				[[a[i][j] for j in range(A__							,				A__     )] for i in range(A__     )]
			__lowerCamelCase					:	Union[str, Any]	       =				[
			    [a[i][j] for j in range(A__							,				A__     )] for i in range(A__							,				A__     )
			]

			__lowerCamelCase					:	Optional[int]	       =				[[a[i][j] for j in range(A__     )] for i in range(A__     )]
			__lowerCamelCase					:	str	       =				[[a[i][j] for j in range(A__     )] for i in range(A__							,				A__     )]

			return top_left, top_right, bot_left, bot_right





def 						UpperCAmelCase				(			A__:    list     )  ->     tuple[int, int]:
			return len(A__     ), len(matrix[0]     )





def 						UpperCAmelCase				(			A__:    list     )  ->     None:
			print('\n'.join(str(A__     ) for line in matrix     )     )





def 						UpperCAmelCase				(			A__:    list							,				A__:    list     )  ->     list:
			if matrix_dimensions(A__     ) == (2, 2):
						return default_matrix_multiplication(A__							,				A__     )

			__lowerCamelCase					:	Any	       =				split_matrix(A__     )
			__lowerCamelCase					:	int	       =				split_matrix(A__     )

			__lowerCamelCase					:	Union[str, Any]	       =				actual_strassen(A__							,				matrix_subtraction(A__							,				A__     )     )
			__lowerCamelCase					:	str	       =				actual_strassen(matrix_addition(A__							,				A__     )							,				A__     )
			__lowerCamelCase					:	List[Any]	       =				actual_strassen(matrix_addition(A__							,				A__     )							,				A__     )
			__lowerCamelCase					:	Any	       =				actual_strassen(A__							,				matrix_subtraction(A__							,				A__     )     )
			__lowerCamelCase					:	Optional[int]	       =				actual_strassen(matrix_addition(A__							,				A__     )							,				matrix_addition(A__							,				A__     )     )
			__lowerCamelCase					:	Dict	       =				actual_strassen(matrix_subtraction(A__							,				A__     )							,				matrix_addition(A__							,				A__     )     )
			__lowerCamelCase					:	Optional[int]	       =				actual_strassen(matrix_subtraction(A__							,				A__     )							,				matrix_addition(A__							,				A__     )     )

			__lowerCamelCase					:	str	       =				matrix_addition(matrix_subtraction(matrix_addition(A__							,				A__     )							,				A__     )							,				A__     )
			__lowerCamelCase					:	Union[str, Any]	       =				matrix_addition(A__							,				A__     )
			__lowerCamelCase					:	List[str]	       =				matrix_addition(A__							,				A__     )
			__lowerCamelCase					:	Optional[Any]	       =				matrix_subtraction(matrix_subtraction(matrix_addition(A__							,				A__     )							,				A__     )							,				A__     )

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





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

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

			__lowerCamelCase					:	Optional[Any]	       =				max(*A__							,				*A__     )
			__lowerCamelCase					:	Optional[Any]	       =				int(math.pow(2							,				math.ceil(math.loga(A__     )     )     )     )
			__lowerCamelCase					:	List[Any]	       =				matrixa
			__lowerCamelCase					:	Optional[Any]	       =				matrixa

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

			__lowerCamelCase					:	Optional[Any]	       =				actual_strassen(A__							,				A__     )

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


if __name__ == "__main__":
					a_				:    List[str]							=     [
					    [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],
					]
					a_				:    Tuple							=     [[0, 2, 1, 1], [16, 2, 3, 3], [2, 2, 7, 7], [13, 11, 22, 4]]
					print(strassen(matrixa, matrixa))









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


a_				:    Tuple										=     logging.get_logger(__name__)

a_				:    str										=     {'''openai-gpt''': '''https://huggingface.co/openai-gpt/resolve/main/config.json'''}

class __lowercase(      lowercase__				):




					'''simple docstring'''


					__a						:						Union[str, Any]     		= 'openai-gpt'
					__a						:						List[Any]     		= {
					    'max_position_embeddings': 'n_positions',
					    'hidden_size': 'n_embd',
					    'num_attention_heads': 'n_head',
					    'num_hidden_layers': 'n_layer',
					}
					def __init__(    self						,	__a=40478						,	__a=512						,	__a=768						,	__a=12						,	__a=12						,	__a="gelu"						,	__a=0.1						,	__a=0.1						,	__a=0.1						,	__a=1E-5						,	__a=0.02						,	__a="cls_index"						,	__a=True						,	__a=None						,	__a=True						,	__a=0.1						,	**__a						,	):
								__lowerCamelCase					:	List[str]	       =				vocab_size
								__lowerCamelCase					:	Union[str, Any]	       =				n_positions
								__lowerCamelCase					:	Optional[Any]	       =				n_embd
								__lowerCamelCase					:	int	       =				n_layer
								__lowerCamelCase					:	List[str]	       =				n_head
								__lowerCamelCase					:	Dict	       =				afn
								__lowerCamelCase					:	Optional[Any]	       =				resid_pdrop
								__lowerCamelCase					:	int	       =				embd_pdrop
								__lowerCamelCase					:	int	       =				attn_pdrop
								__lowerCamelCase					:	Dict	       =				layer_norm_epsilon
								__lowerCamelCase					:	List[str]	       =				initializer_range
								__lowerCamelCase					:	Any	       =				summary_type
								__lowerCamelCase					:	Tuple	       =				summary_use_proj
								__lowerCamelCase					:	List[Any]	       =				summary_activation
								__lowerCamelCase					:	str	       =				summary_first_dropout
								__lowerCamelCase					:	Tuple	       =				summary_proj_to_labels
								super().__init__(**__a     )



