
'''simple docstring'''







def  snake_case_		(    __SCREAMING_SNAKE_CASE :			int							):



						"""simple docstring"""





						lowercase_     :					List[Any]													=	generate_pascal_triangle(__SCREAMING_SNAKE_CASE							)
						for row_idx in range(__SCREAMING_SNAKE_CASE							):
												# 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  snake_case_		(    __SCREAMING_SNAKE_CASE :			int							):



						"""simple docstring"""





						if not isinstance(__SCREAMING_SNAKE_CASE				,				__SCREAMING_SNAKE_CASE							):
												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'''							)

						lowercase_     :					list[list[int]]													=	[]
						for current_row_idx in range(__SCREAMING_SNAKE_CASE							):
												lowercase_     :					Optional[Any]													=	populate_current_row(__SCREAMING_SNAKE_CASE				,				__SCREAMING_SNAKE_CASE							)
												triangle.append(__SCREAMING_SNAKE_CASE							)
						return triangle
def  snake_case_		(    __SCREAMING_SNAKE_CASE :			list[list[int]]				,				__SCREAMING_SNAKE_CASE :			int							):



						"""simple docstring"""





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



						"""simple docstring"""





						lowercase_     :					Dict													=	triangle[current_row_idx - 1][current_col_idx - 1]
						lowercase_     :					Optional[Any]													=	triangle[current_row_idx - 1][current_col_idx]
						lowercase_     :					List[Any]													=	above_to_left_elt + above_to_right_elt
def  snake_case_		(    __SCREAMING_SNAKE_CASE :			int							):



						"""simple docstring"""





						if not isinstance(__SCREAMING_SNAKE_CASE				,				__SCREAMING_SNAKE_CASE							):
												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'''							)

						lowercase_     :					list[list[int]]													=	[[1]]

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

						return result
def  snake_case_		(    ):



						"""simple docstring"""





						from collections.abc import Callable
						from timeit import timeit

						def benchmark_a_function(__SCREAMING_SNAKE_CASE :			Callable				,				__SCREAMING_SNAKE_CASE :			int							) -> None:
												lowercase_     :					Tuple													=	F'''{func.__name__}({value})'''
												lowercase_     :					List[Any]													=	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(15							):  # (1, 7, 14):
												for func in (generate_pascal_triangle, generate_pascal_triangle_optimized):
																		benchmark_a_function(__SCREAMING_SNAKE_CASE				,				__SCREAMING_SNAKE_CASE							)
												print()


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							benchmark()





'''simple docstring'''







import unittest

from datasets import load_dataset

from transformers import BloomTokenizerFast
from transformers.testing_utils import require_tokenizers

from ...test_tokenization_common import TokenizerTesterMixin






@require_tokenizers
class 			lowerCAmelCase__       (  lowerCamelCase_   ,						unittest.TestCase					):
					lowerCAmelCase_					       =					None
					lowerCAmelCase_					       =					BloomTokenizerFast
					lowerCAmelCase_					       =					BloomTokenizerFast
					lowerCAmelCase_					       =					True
					lowerCAmelCase_					       =					False
					lowerCAmelCase_					       =					'''tokenizer_file'''
					lowerCAmelCase_					       =					{'''bos_token''': '''<s>''', '''eos_token''': '''</s>''', '''unk_token''': '''<unk>''', '''pad_token''': '''<pad>'''}






					def      _snake_case   (       self		):


											"""simple docstring"""





											super().setUp()
											lowercase_     :					List[Any]													=	BloomTokenizerFast.from_pretrained('''bigscience/tokenizer'''		)
											tokenizer.save_pretrained(self.tmpdirname		)






					def      _snake_case   (       self    ,							**__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											kwargs.update(self.special_tokens_map		)
											return BloomTokenizerFast.from_pretrained(self.tmpdirname    ,							**__SCREAMING_SNAKE_CASE		)






					def      _snake_case   (       self		):


											"""simple docstring"""





											lowercase_     :					Tuple													=	self.get_rust_tokenizer()

											lowercase_     :					Optional[Any]													=	['''The quick brown fox</s>''', '''jumps over the lazy dog</s>''']
											lowercase_     :					Union[str, Any]													=	[[21_75, 2_37_14, 7_31_73, 14_42_52, 2], [77, 13_26_19, 34_78, 3_68, 10_95_86, 3_54_33, 2]]

											lowercase_     :					Dict													=	tokenizer.batch_encode_plus(__SCREAMING_SNAKE_CASE		)['''input_ids''']
											self.assertListEqual(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		)

											lowercase_     :					Tuple													=	tokenizer.batch_decode(__SCREAMING_SNAKE_CASE		)
											self.assertListEqual(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		)






					def      _snake_case   (       self    ,							__SCREAMING_SNAKE_CASE=6		):


											"""simple docstring"""





											for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
																	with self.subTest(F'''{tokenizer.__class__.__name__} ({pretrained_name})'''		):
																							lowercase_     :					int													=	self.rust_tokenizer_class.from_pretrained(__SCREAMING_SNAKE_CASE    ,							**__SCREAMING_SNAKE_CASE		)
																							# tokenizer_r.pad_token = None # Hotfixing padding = None
																							# Simple input
																							lowercase_     :					Optional[int]													=	'''This is a simple input'''
																							lowercase_     :					List[str]													=	['''This is a simple input 1''', '''This is a simple input 2''']
																							lowercase_     :					List[str]													=	('''This is a simple input''', '''This is a pair''')
																							lowercase_     :					Union[str, Any]													=	[
																							    ('''This is a simple input 1''', '''This is a simple input 2'''),
																							    ('''This is a simple pair 1''', '''This is a simple pair 2'''),
																							]

																							# Simple input tests
																							try:
																													tokenizer_r.encode(__SCREAMING_SNAKE_CASE    ,							max_length=__SCREAMING_SNAKE_CASE		)
																													tokenizer_r.encode_plus(__SCREAMING_SNAKE_CASE    ,							max_length=__SCREAMING_SNAKE_CASE		)

																													tokenizer_r.batch_encode_plus(__SCREAMING_SNAKE_CASE    ,							max_length=__SCREAMING_SNAKE_CASE		)
																													tokenizer_r.encode(__SCREAMING_SNAKE_CASE    ,							max_length=__SCREAMING_SNAKE_CASE		)
																													tokenizer_r.batch_encode_plus(__SCREAMING_SNAKE_CASE    ,							max_length=__SCREAMING_SNAKE_CASE		)
																							except ValueError:
																													self.fail('''Bloom Tokenizer should be able to deal with padding'''		)

																							lowercase_     :					Optional[Any]													=	None  # Hotfixing padding = None
																							self.assertRaises(__SCREAMING_SNAKE_CASE    ,							tokenizer_r.encode    ,							__SCREAMING_SNAKE_CASE    ,							max_length=__SCREAMING_SNAKE_CASE    ,							padding='''max_length'''		)

																							# Simple input
																							self.assertRaises(__SCREAMING_SNAKE_CASE    ,							tokenizer_r.encode_plus    ,							__SCREAMING_SNAKE_CASE    ,							max_length=__SCREAMING_SNAKE_CASE    ,							padding='''max_length'''		)

																							# Simple input
																							self.assertRaises(
																							    __SCREAMING_SNAKE_CASE    ,							tokenizer_r.batch_encode_plus    ,							__SCREAMING_SNAKE_CASE    ,							max_length=__SCREAMING_SNAKE_CASE    ,							padding='''max_length'''    ,							)

																							# Pair input
																							self.assertRaises(__SCREAMING_SNAKE_CASE    ,							tokenizer_r.encode    ,							__SCREAMING_SNAKE_CASE    ,							max_length=__SCREAMING_SNAKE_CASE    ,							padding='''max_length'''		)

																							# Pair input
																							self.assertRaises(__SCREAMING_SNAKE_CASE    ,							tokenizer_r.encode_plus    ,							__SCREAMING_SNAKE_CASE    ,							max_length=__SCREAMING_SNAKE_CASE    ,							padding='''max_length'''		)

																							# Pair input
																							self.assertRaises(
																							    __SCREAMING_SNAKE_CASE    ,							tokenizer_r.batch_encode_plus    ,							__SCREAMING_SNAKE_CASE    ,							max_length=__SCREAMING_SNAKE_CASE    ,							padding='''max_length'''    ,							)






					def      _snake_case   (       self		):


											"""simple docstring"""





											lowercase_     :					List[str]													=	self.get_rust_tokenizer()
											lowercase_     :					Tuple													=	load_dataset('''xnli'''    ,							'''all_languages'''    ,							split='''test'''    ,							streaming=__SCREAMING_SNAKE_CASE		)

											lowercase_     :					Optional[int]													=	next(iter(__SCREAMING_SNAKE_CASE		)		)['''premise''']  # pick up one data
											lowercase_     :					List[Any]													=	list(sample_data.values()		)

											lowercase_     :					Tuple													=	list(map(tokenizer.encode    ,							__SCREAMING_SNAKE_CASE		)		)
											lowercase_     :					Any													=	[tokenizer.decode(__SCREAMING_SNAKE_CASE    ,							clean_up_tokenization_spaces=__SCREAMING_SNAKE_CASE		) for x in output_tokens]
											self.assertListEqual(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		)






					def      _snake_case   (       self		):


											"""simple docstring"""





											self.assertGreaterEqual(len(self.tokenizer_class.pretrained_vocab_files_map		)    ,							1		)
											self.assertGreaterEqual(len(list(self.tokenizer_class.pretrained_vocab_files_map.values()		)[0]		)    ,							1		)



