'''simple docstring'''

import timeit







class     _lowercase					:


	'''simple docstring'''






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





	def __mul__(				self       :     int				,	SCREAMING_SNAKE_CASE__       :     List[str]							)  ->   Dict:
		__lowerCAmelCase    							=						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 					UpperCamelCase_						( snake_case_	:	List[str]						,		snake_case_	:	Optional[Any]				) ->					int:






	'''simple docstring'''

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







def 					UpperCamelCase_						( snake_case_	:	Tuple						,		snake_case_	:	int						,		snake_case_	:	Optional[Any]				) ->					Dict:






	'''simple docstring'''

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







def 					UpperCamelCase_						( snake_case_	:	Optional[int]						,		snake_case_	:	List[Any]						,		snake_case_	:	Optional[Any]				) ->					List[str]:






	'''simple docstring'''

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

	__lowerCAmelCase    							=						fa
	__lowerCAmelCase    							=						fa
	n -= 2

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

	return fn_a







def 					UpperCamelCase_						( ) ->					Union[str, Any]:






	'''simple docstring'''

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







def 					UpperCamelCase_						( ) ->					Any:






	'''simple docstring'''

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







def 					UpperCamelCase_						( ) ->					Tuple:






	'''simple docstring'''

	matrix_exponentiation_time()
	simple_fibonacci_time()


if __name__ == "__main__":
	main()







'''simple docstring'''

from unittest.mock import patch

import datasets
from datasets import Dataset







def 					UpperCamelCase_						( ) ->					Dict:






 '''simple docstring'''

 __lowerCAmelCase    							=						Dataset.from_dict({"""col_1""": [3, 2, 0, 1]}				)

 with patch("""tqdm.auto.tqdm"""				) as mock_tqdm:
  datasets.disable_progress_bar()
  dset.map(lambda snake_case_				: {"col_2": x["col_1"] + 1}				)
  mock_tqdm.assert_not_called()

  mock_tqdm.reset_mock()

  datasets.enable_progress_bar()
  dset.map(lambda snake_case_				: {"col_2": x["col_1"] + 1}				)
  mock_tqdm.assert_called()






