


from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments






def 							__lowercase     (				):
							a__    =  HfArgumentParser(__lowerCAmelCase     )
							a__    =  parser.parse_args_into_dataclasses()[0]
							a__    =  TensorFlowBenchmark(args=__lowerCAmelCase     )
							try:
														a__    =  parser.parse_args_into_dataclasses()[0]
							except ValueError as e:
														a__    =  'Arg --no_{0} is no longer used, please use --no-{0} instead.'
														a__    =  ' '.join(str(__lowerCAmelCase     ).split(' '     )[:-1]     )
														a__    =  ''
														a__    =  eval(str(__lowerCAmelCase     ).split(' '     )[-1]     )
														a__    =  []
														for arg in depreciated_args:
																					# arg[2:] removes '--'
																					if arg[2:] in TensorFlowBenchmark.deprecated_args:
																												# arg[5:] removes '--no_'
																												full_error_msg += arg_error_msg.format(arg[5:]     )
																					else:
																												wrong_args.append(__lowerCAmelCase     )
														if len(__lowerCAmelCase     ) > 0:
																					a__    =  full_error_msg + begin_error_msg + str(__lowerCAmelCase     )
														raise ValueError(__lowerCAmelCase     )
							benchmark.run()


if __name__ == "__main__":
						main()








def 							__lowercase     (				__lowerCAmelCase							:       int     ):
							a__    =  generate_pascal_triangle(__lowerCAmelCase     )
							for row_idx in range(__lowerCAmelCase     ):
														# Print left spaces
														for _ in range(num_rows - row_idx - 1     ):
																					print(end=' '     )
														# Print row values
														for col_idx in range(row_idx + 1     ):
																					if col_idx != row_idx:
																												print(triangle[row_idx][col_idx]      ,					end=' '     )
																					else:
																												print(triangle[row_idx][col_idx]      ,					end=''     )
														print()






def 							__lowercase     (				__lowerCAmelCase							:       int     ):

							if not isinstance(__lowerCAmelCase      ,					__lowerCAmelCase     ):
														raise TypeError('The input value of \'num_rows\' should be \'int\''     )

							if num_rows == 0:
														return []
							elif num_rows < 0:
														raise ValueError(
														    'The input value of \'num_rows\' should be greater than or equal to 0'     )

							a__    =  []
							for current_row_idx in range(__lowerCAmelCase     ):
														a__    =  populate_current_row(__lowerCAmelCase      ,					__lowerCAmelCase     )
														triangle.append(__lowerCAmelCase     )
							return triangle






def 							__lowercase     (				__lowerCAmelCase							:       list[list[int]]      ,					__lowerCAmelCase							:       int     ):
							a__    =  [-1] * (current_row_idx + 1)
							# first and last elements of current row are equal to 1
							a__   ,      a__    =  1, 1
							for current_col_idx in range(1      ,					__lowerCAmelCase     ):
														calculate_current_element(
														    __lowerCAmelCase      ,					__lowerCAmelCase      ,					__lowerCAmelCase      ,					__lowerCAmelCase     )
							return current_row






def 							__lowercase     (				__lowerCAmelCase							:       list[list[int]]      ,					__lowerCAmelCase							:       list[int]      ,					__lowerCAmelCase							:       int      ,					__lowerCAmelCase							:       int      ,					):
							a__    =  triangle[current_row_idx - 1][current_col_idx - 1]
							a__    =  triangle[current_row_idx - 1][current_col_idx]
							a__    =  above_to_left_elt + above_to_right_elt






def 							__lowercase     (				__lowerCAmelCase							:       int     ):

							if not isinstance(__lowerCAmelCase      ,					__lowerCAmelCase     ):
														raise TypeError('The input value of \'num_rows\' should be \'int\''     )

							if num_rows == 0:
														return []
							elif num_rows < 0:
														raise ValueError(
														    'The input value of \'num_rows\' should be greater than or equal to 0'     )

							a__    =  [[1]]

							for row_index in range(1      ,					__lowerCAmelCase     ):
														a__    =  [0] + result[-1] + [0]
														a__    =  row_index + 1
														# Calculate the number of distinct elements in a row
														a__    =  sum(divmod(__lowerCAmelCase      ,					2     )     )
														a__    =  [
														    temp_row[i - 1] + temp_row[i] for i in range(1      ,					distinct_elements + 1     )
														]
														a__    =  row_first_half[: (row_index + 1) // 2]
														row_second_half.reverse()
														a__    =  row_first_half + row_second_half
														result.append(__lowerCAmelCase     )

							return result






def 							__lowercase     (				):
							from collections.abc import Callable
							from timeit import timeit

							def benchmark_a_function(__lowerCAmelCase							:       Callable      ,					__lowerCAmelCase							:       int     ) -> None:
														a__    =  F'{func.__name__}({value})'
														a__    =  timeit(F'__main__.{call}'      ,					setup='import __main__'     )
														# print(f"{call:38} = {func(value)} -- {timing:.4f} seconds")
														print(F'{call:38} -- {timing:.4f} seconds'     )

							for value in range(1_5     ):  # (1, 7, 14):
														for func in (generate_pascal_triangle, generate_pascal_triangle_optimized):
																					benchmark_a_function(__lowerCAmelCase      ,					__lowerCAmelCase     )
														print()


if __name__ == "__main__":
						import doctest

						doctest.testmod()
						benchmark()




