


'''simple docstring'''
from __future__ import annotations

import math


def     a   (    __a				,      __a     )						->			list:



					'''simple docstring'''






					if len(__a     ) != 2 or len(a[0]     ) != 2 or len(__a     ) != 2 or len(b[0]     ) != 2:
										raise Exception('''Matrices are not 2x2'''     )
					UpperCamelCase__     :List[str]							      =				[
					    [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   (    __a				,      __a     )						->			str:



					'''simple docstring'''






					return [
					    [matrix_a[row][col] + matrix_b[row][col] for col in range(len(matrix_a[row]     )     )]
					    for row in range(len(__a     )     )
					]


def     a   (    __a				,      __a     )						->			Tuple:



					'''simple docstring'''






					return [
					    [matrix_a[row][col] - matrix_b[row][col] for col in range(len(matrix_a[row]     )     )]
					    for row in range(len(__a     )     )
					]


def     a   (    __a     )						->			tuple[list, list, list, list]:



					'''simple docstring'''






					if len(__a     ) % 2 != 0 or len(a[0]     ) % 2 != 0:
										raise Exception('''Odd matrices are not supported!'''     )

					UpperCamelCase__     :str							      =				len(__a     )
					UpperCamelCase__     :Optional[int]							      =				matrix_length // 2

					UpperCamelCase__     :Optional[Any]							      =				[[a[i][j] for j in range(__a				,      __a     )] for i in range(__a     )]
					UpperCamelCase__     :Tuple							      =				[
					    [a[i][j] for j in range(__a				,      __a     )] for i in range(__a				,      __a     )
					]

					UpperCamelCase__     :Tuple							      =				[[a[i][j] for j in range(__a     )] for i in range(__a     )]
					UpperCamelCase__     :Optional[Any]							      =				[[a[i][j] for j in range(__a     )] for i in range(__a				,      __a     )]

					return top_left, top_right, bot_left, bot_right


def     a   (    __a     )						->			tuple[int, int]:



					'''simple docstring'''






					return len(__a     ), len(matrix[0]     )


def     a   (    __a     )						->			None:



					'''simple docstring'''






					print('''\n'''.join(str(__a     ) for line in matrix     )     )


def     a   (    __a				,      __a     )						->			list:



					'''simple docstring'''






					if matrix_dimensions(__a     ) == (2, 2):
										return default_matrix_multiplication(__a				,      __a     )

					UpperCamelCase__      ,       UpperCamelCase__      ,       UpperCamelCase__      ,       UpperCamelCase__     :Optional[Any]							      =				split_matrix(__a     )
					UpperCamelCase__      ,       UpperCamelCase__      ,       UpperCamelCase__      ,       UpperCamelCase__     :List[Any]							      =				split_matrix(__a     )

					UpperCamelCase__     :Optional[Any]							      =				actual_strassen(__a				,      matrix_subtraction(__a				,      __a     )     )
					UpperCamelCase__     :Dict							      =				actual_strassen(matrix_addition(__a				,      __a     )				,      __a     )
					UpperCamelCase__     :Any							      =				actual_strassen(matrix_addition(__a				,      __a     )				,      __a     )
					UpperCamelCase__     :Dict							      =				actual_strassen(__a				,      matrix_subtraction(__a				,      __a     )     )
					UpperCamelCase__     :Union[str, Any]							      =				actual_strassen(matrix_addition(__a				,      __a     )				,      matrix_addition(__a				,      __a     )     )
					UpperCamelCase__     :Dict							      =				actual_strassen(matrix_subtraction(__a				,      __a     )				,      matrix_addition(__a				,      __a     )     )
					UpperCamelCase__     :Dict							      =				actual_strassen(matrix_subtraction(__a				,      __a     )				,      matrix_addition(__a				,      __a     )     )

					UpperCamelCase__     :Optional[int]							      =				matrix_addition(matrix_subtraction(matrix_addition(__a				,      __a     )				,      __a     )				,      __a     )
					UpperCamelCase__     :int							      =				matrix_addition(__a				,      __a     )
					UpperCamelCase__     :int							      =				matrix_addition(__a				,      __a     )
					UpperCamelCase__     :Optional[int]							      =				matrix_subtraction(matrix_subtraction(matrix_addition(__a				,      __a     )				,      __a     )				,      __a     )

					# construct the new matrix from our 4 quadrants
					UpperCamelCase__     :Tuple							      =				[]
					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     a   (    __a				,      __a     )						->			list:



					'''simple docstring'''






					if matrix_dimensions(__a     )[1] != matrix_dimensions(__a     )[0]:
										UpperCamelCase__     :int							      =				(
										    '''Unable to multiply these matrices, please check the dimensions.\n'''
										    f'''Matrix A: {matrixa}\n'''
										    f'''Matrix B: {matrixa}'''
										)
										raise Exception(__a     )
					UpperCamelCase__     :Any							      =				matrix_dimensions(__a     )
					UpperCamelCase__     :List[Any]							      =				matrix_dimensions(__a     )

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

					UpperCamelCase__     :Optional[int]							      =				max(*__a				,      *__a     )
					UpperCamelCase__     :Tuple							      =				int(math.pow(2				,      math.ceil(math.loga(__a     )     )     )     )
					UpperCamelCase__     :Optional[int]							      =				matrixa
					UpperCamelCase__     :Tuple							      =				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     )

					UpperCamelCase__     :Tuple							      =				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__":
		__snake_case							   =  [
		    [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],
		]
		__snake_case							   =  [[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


__snake_case							   =  logging.get_logger(__name__)

__snake_case							   =  {
    '''transfo-xl-wt103''': '''https://huggingface.co/transfo-xl-wt103/resolve/main/config.json''',
}
class      lowercase			(							A__      ):

		"""simple docstring"""

		_a									=       'transfo-xl'
		_a									=       ['mems']
		_a									=       {
		    'n_token': 'vocab_size',
		    'hidden_size': 'd_model',
		    'num_attention_heads': 'n_head',
		    'num_hidden_layers': 'n_layer',
		}




		def __init__(	self					,     UpperCamelCase_=267735					,     UpperCamelCase_=[20000, 40000, 200000]					,     UpperCamelCase_=1024					,     UpperCamelCase_=1024					,     UpperCamelCase_=16					,     UpperCamelCase_=64					,     UpperCamelCase_=4096					,     UpperCamelCase_=4					,     UpperCamelCase_=False					,     UpperCamelCase_=18					,     UpperCamelCase_=1600					,     UpperCamelCase_=1000					,     UpperCamelCase_=True					,     UpperCamelCase_=True					,     UpperCamelCase_=0					,     UpperCamelCase_=-1					,     UpperCamelCase_=True					,     UpperCamelCase_=0.1					,     UpperCamelCase_=0.0					,     UpperCamelCase_=True					,     UpperCamelCase_="normal"					,     UpperCamelCase_=0.01					,     UpperCamelCase_=0.01					,     UpperCamelCase_=0.02					,     UpperCamelCase_=1e-5					,     UpperCamelCase_=0					,     **UpperCamelCase_					,     ):

							'''simple docstring'''


							UpperCamelCase__     :Dict							      =				vocab_size
							UpperCamelCase__     :Optional[int]							      =				[]
							self.cutoffs.extend(UpperCamelCase_							)
							if proj_share_all_but_first:
												UpperCamelCase__     :Any							      =				[False] + [True] * len(self.cutoffs							)
							else:
												UpperCamelCase__     :Dict							      =				[False] + [False] * len(self.cutoffs							)
							UpperCamelCase__     :Union[str, Any]							      =				d_model
							UpperCamelCase__     :List[Any]							      =				d_embed
							UpperCamelCase__     :Any							      =				d_head
							UpperCamelCase__     :Tuple							      =				d_inner
							UpperCamelCase__     :int							      =				div_val
							UpperCamelCase__     :int							      =				pre_lnorm
							UpperCamelCase__     :Any							      =				n_layer
							UpperCamelCase__     :int							      =				n_head
							UpperCamelCase__     :Tuple							      =				mem_len
							UpperCamelCase__     :List[str]							      =				same_length
							UpperCamelCase__     :Any							      =				attn_type
							UpperCamelCase__     :List[str]							      =				clamp_len
							UpperCamelCase__     :Union[str, Any]							      =				sample_softmax
							UpperCamelCase__     :List[Any]							      =				adaptive
							UpperCamelCase__     :List[Any]							      =				dropout
							UpperCamelCase__     :Optional[Any]							      =				dropatt
							UpperCamelCase__     :str							      =				untie_r
							UpperCamelCase__     :List[Any]							      =				init
							UpperCamelCase__     :Optional[Any]							      =				init_range
							UpperCamelCase__     :int							      =				proj_init_std
							UpperCamelCase__     :List[str]							      =				init_std
							UpperCamelCase__     :Optional[int]							      =				layer_norm_epsilon
							super().__init__(eos_token_id=UpperCamelCase_					,     **UpperCamelCase_							)




		@property
		def 					lowerCAmelCase__       (	self							):

							'''simple docstring'''


							logger.info(F'''The model {self.model_type} is one of the few models that has no sequence length limit.'''							)
							return -1




		@max_position_embeddings.setter
		def 					lowerCAmelCase__       (	self					,     UpperCamelCase_							):

							'''simple docstring'''


							raise NotImplementedError(
							    F'''The model {self.model_type} is one of the few models that has no sequence length limit.'''							)