
"""simple docstring"""



def 	__snake_case  (    SCREAMING_SNAKE_CASE:					int						):






							"""simple docstring"""



							_lowerCAmelCase  	=			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'						)

							_lowerCAmelCase  	=			[]
							for current_row_idx in range(SCREAMING_SNAKE_CASE						):
														_lowerCAmelCase  	=			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"""



							_lowerCAmelCase  	=			[-1] * (current_row_idx + 1)
							# first and last elements of current row are equal to 1
							_lowerCAmelCase	,		_lowerCAmelCase  	=			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"""



							_lowerCAmelCase  	=			triangle[current_row_idx - 1][current_col_idx - 1]
							_lowerCAmelCase  	=			triangle[current_row_idx - 1][current_col_idx]
							_lowerCAmelCase  	=			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'						)

							_lowerCAmelCase  	=			[[1]]

							for row_index in range(1     ,  SCREAMING_SNAKE_CASE						):
														_lowerCAmelCase  	=			[0] + result[-1] + [0]
														_lowerCAmelCase  	=			row_index + 1
														# Calculate the number of distinct elements in a row
														_lowerCAmelCase  	=			sum(divmod(SCREAMING_SNAKE_CASE     ,  2						)						)
														_lowerCAmelCase  	=			[
														    temp_row[i - 1] + temp_row[i] for i in range(1     ,  distinct_elements + 1						)
														]
														_lowerCAmelCase  	=			row_first_half[: (row_index + 1) // 2]
														row_second_half.reverse()
														_lowerCAmelCase  	=			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:
														_lowerCAmelCase  	=			f"""{func.__name__}({value})"""
														_lowerCAmelCase  	=			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"""



from __future__ import annotations

import unittest

from transformers import DebertaVaConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
	import tensorflow as tf

	from transformers import (
	    TFDebertaVaForMaskedLM,
	    TFDebertaVaForQuestionAnswering,
	    TFDebertaVaForSequenceClassification,
	    TFDebertaVaForTokenClassification,
	    TFDebertaVaModel,
	)
class        _SCREAMING_SNAKE_CASE  :






				'''simple docstring'''



				def __init__(					self	:			Dict				,     UpperCAmelCase_	:			Tuple				,     UpperCAmelCase_	:			Optional[int]=13				,     UpperCAmelCase_	:			Tuple=7				,     UpperCAmelCase_	:			Union[str, Any]=True				,     UpperCAmelCase_	:			int=True				,     UpperCAmelCase_	:			int=True				,     UpperCAmelCase_	:			Optional[int]=True				,     UpperCAmelCase_	:			Dict=99				,     UpperCAmelCase_	:			Tuple=32				,     UpperCAmelCase_	:			str=2				,     UpperCAmelCase_	:			int=4				,     UpperCAmelCase_	:			Any=37				,     UpperCAmelCase_	:			str="gelu"				,     UpperCAmelCase_	:			Union[str, Any]=0.1				,     UpperCAmelCase_	:			str=0.1				,     UpperCAmelCase_	:			int=512				,     UpperCAmelCase_	:			str=16				,     UpperCAmelCase_	:			str=2				,     UpperCAmelCase_	:			Union[str, Any]=0.02				,     UpperCAmelCase_	:			List[str]=False				,     UpperCAmelCase_	:			List[Any]=True				,     UpperCAmelCase_	:			Optional[int]="None"				,     UpperCAmelCase_	:			List[Any]=3				,     UpperCAmelCase_	:			Any=4				,     UpperCAmelCase_	:			Tuple=None				,     )		->  Optional[Any]:







											"""simple docstring"""




											_lowerCAmelCase  	=			parent
											_lowerCAmelCase  	=			batch_size
											_lowerCAmelCase  	=			seq_length
											_lowerCAmelCase  	=			is_training
											_lowerCAmelCase  	=			use_input_mask
											_lowerCAmelCase  	=			use_token_type_ids
											_lowerCAmelCase  	=			use_labels
											_lowerCAmelCase  	=			vocab_size
											_lowerCAmelCase  	=			hidden_size
											_lowerCAmelCase  	=			num_hidden_layers
											_lowerCAmelCase  	=			num_attention_heads
											_lowerCAmelCase  	=			intermediate_size
											_lowerCAmelCase  	=			hidden_act
											_lowerCAmelCase  	=			hidden_dropout_prob
											_lowerCAmelCase  	=			attention_probs_dropout_prob
											_lowerCAmelCase  	=			max_position_embeddings
											_lowerCAmelCase  	=			type_vocab_size
											_lowerCAmelCase  	=			type_sequence_label_size
											_lowerCAmelCase  	=			initializer_range
											_lowerCAmelCase  	=			num_labels
											_lowerCAmelCase  	=			num_choices
											_lowerCAmelCase  	=			relative_attention
											_lowerCAmelCase  	=			position_biased_input
											_lowerCAmelCase  	=			pos_att_type
											_lowerCAmelCase  	=			scope


				def 				__lowerCamelCase	(					self	:			Tuple  )		->  Optional[Any]:







											"""simple docstring"""




											_lowerCAmelCase  	=			ids_tensor([self.batch_size, self.seq_length]				,     self.vocab_size  )

											_lowerCAmelCase  	=			None
											if self.use_input_mask:
																		_lowerCAmelCase  	=			random_attention_mask([self.batch_size, self.seq_length]  )

											_lowerCAmelCase  	=			None
											if self.use_token_type_ids:
																		_lowerCAmelCase  	=			ids_tensor([self.batch_size, self.seq_length]				,     self.type_vocab_size  )

											_lowerCAmelCase  	=			None
											_lowerCAmelCase  	=			None
											_lowerCAmelCase  	=			None
											if self.use_labels:
																		_lowerCAmelCase  	=			ids_tensor([self.batch_size]				,     self.type_sequence_label_size  )
																		_lowerCAmelCase  	=			ids_tensor([self.batch_size, self.seq_length]				,     self.num_labels  )

											_lowerCAmelCase  	=			DebertaVaConfig(
											    vocab_size=self.vocab_size				,     hidden_size=self.hidden_size				,     num_hidden_layers=self.num_hidden_layers				,     num_attention_heads=self.num_attention_heads				,     intermediate_size=self.intermediate_size				,     hidden_act=self.hidden_act				,     hidden_dropout_prob=self.hidden_dropout_prob				,     attention_probs_dropout_prob=self.attention_probs_dropout_prob				,     max_position_embeddings=self.max_position_embeddings				,     type_vocab_size=self.type_vocab_size				,     relative_attention=self.relative_attention				,     position_biased_input=self.position_biased_input				,     initializer_range=self.initializer_range				,     return_dict=UpperCAmelCase_				,     )

											return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels


				def 				__lowerCamelCase	(					self	:			Tuple				,     UpperCAmelCase_	:			Any				,     UpperCAmelCase_	:			Union[str, Any]				,     UpperCAmelCase_	:			Any				,     UpperCAmelCase_	:			List[Any]				,     UpperCAmelCase_	:			Tuple				,     UpperCAmelCase_	:			int				,     UpperCAmelCase_	:			Tuple  )		->  int:







											"""simple docstring"""




											_lowerCAmelCase  	=			TFDebertaVaModel(config=UpperCAmelCase_  )
											_lowerCAmelCase  	=			{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}

											_lowerCAmelCase  	=			[input_ids, input_mask]
											_lowerCAmelCase  	=			model(UpperCAmelCase_  )

											_lowerCAmelCase  	=			model(UpperCAmelCase_  )

											self.parent.assertEqual(result.last_hidden_state.shape				,     (self.batch_size, self.seq_length, self.hidden_size)  )


				def 				__lowerCamelCase	(					self	:			Tuple				,     UpperCAmelCase_	:			Dict				,     UpperCAmelCase_	:			List[Any]				,     UpperCAmelCase_	:			Any				,     UpperCAmelCase_	:			Optional[Any]				,     UpperCAmelCase_	:			Union[str, Any]				,     UpperCAmelCase_	:			Optional[Any]				,     UpperCAmelCase_	:			Any  )		->  Optional[int]:







											"""simple docstring"""




											_lowerCAmelCase  	=			TFDebertaVaForMaskedLM(config=UpperCAmelCase_  )
											_lowerCAmelCase  	=			{
											    'input_ids': input_ids,
											    'attention_mask': input_mask,
											    'token_type_ids': token_type_ids,
											}
											_lowerCAmelCase  	=			model(UpperCAmelCase_  )
											self.parent.assertEqual(result.logits.shape				,     (self.batch_size, self.seq_length, self.vocab_size)  )


				def 				__lowerCamelCase	(					self	:			Any				,     UpperCAmelCase_	:			List[str]				,     UpperCAmelCase_	:			Any				,     UpperCAmelCase_	:			List[Any]				,     UpperCAmelCase_	:			List[str]				,     UpperCAmelCase_	:			Dict				,     UpperCAmelCase_	:			Optional[Any]				,     UpperCAmelCase_	:			int  )		->  List[str]:







											"""simple docstring"""




											_lowerCAmelCase  	=			self.num_labels
											_lowerCAmelCase  	=			TFDebertaVaForSequenceClassification(config=UpperCAmelCase_  )
											_lowerCAmelCase  	=			{
											    'input_ids': input_ids,
											    'attention_mask': input_mask,
											    'token_type_ids': token_type_ids,
											}

											_lowerCAmelCase  	=			model(UpperCAmelCase_  )
											self.parent.assertEqual(result.logits.shape				,     (self.batch_size, self.num_labels)  )


				def 				__lowerCamelCase	(					self	:			int				,     UpperCAmelCase_	:			int				,     UpperCAmelCase_	:			str				,     UpperCAmelCase_	:			List[Any]				,     UpperCAmelCase_	:			List[Any]				,     UpperCAmelCase_	:			Any				,     UpperCAmelCase_	:			List[str]				,     UpperCAmelCase_	:			Optional[Any]  )		->  Tuple:







											"""simple docstring"""




											_lowerCAmelCase  	=			self.num_labels
											_lowerCAmelCase  	=			TFDebertaVaForTokenClassification(config=UpperCAmelCase_  )
											_lowerCAmelCase  	=			{
											    'input_ids': input_ids,
											    'attention_mask': input_mask,
											    'token_type_ids': token_type_ids,
											}
											_lowerCAmelCase  	=			model(UpperCAmelCase_  )
											self.parent.assertEqual(result.logits.shape				,     (self.batch_size, self.seq_length, self.num_labels)  )


				def 				__lowerCamelCase	(					self	:			Tuple				,     UpperCAmelCase_	:			Union[str, Any]				,     UpperCAmelCase_	:			Any				,     UpperCAmelCase_	:			int				,     UpperCAmelCase_	:			Union[str, Any]				,     UpperCAmelCase_	:			Tuple				,     UpperCAmelCase_	:			List[Any]				,     UpperCAmelCase_	:			List[str]  )		->  List[Any]:







											"""simple docstring"""




											_lowerCAmelCase  	=			TFDebertaVaForQuestionAnswering(config=UpperCAmelCase_  )
											_lowerCAmelCase  	=			{
											    'input_ids': input_ids,
											    'attention_mask': input_mask,
											    'token_type_ids': token_type_ids,
											}

											_lowerCAmelCase  	=			model(UpperCAmelCase_  )
											self.parent.assertEqual(result.start_logits.shape				,     (self.batch_size, self.seq_length)  )
											self.parent.assertEqual(result.end_logits.shape				,     (self.batch_size, self.seq_length)  )







				def 				__lowerCamelCase	(					self	:			List[Any]  )		->  List[Any]:







											"""simple docstring"""




											_lowerCAmelCase  	=			self.prepare_config_and_inputs()
											(
											    (
											    _lowerCAmelCase
											)	,		(
											    _lowerCAmelCase
											)	,		(
											    _lowerCAmelCase
											)	,		(
											    _lowerCAmelCase
											)	,		(
											    _lowerCAmelCase
											)	,		(
											    _lowerCAmelCase
											)	,		(
											    _lowerCAmelCase
											)	,		
											)  	=			config_and_inputs
											_lowerCAmelCase  	=			{'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
											return config, inputs_dict






@require_tf
class        _SCREAMING_SNAKE_CASE  (  UpperCAmelCase      ,				UpperCAmelCase      ,				unittest.TestCase							):






				'''simple docstring'''



				SCREAMING_SNAKE_CASE_:							List[str]							=					(
				    (
				        TFDebertaVaModel,
				        TFDebertaVaForMaskedLM,
				        TFDebertaVaForQuestionAnswering,
				        TFDebertaVaForSequenceClassification,
				        TFDebertaVaForTokenClassification,
				    )
				    if is_tf_available()
				    else ()
				)
				SCREAMING_SNAKE_CASE_:							str							=					(
				    {
				        "feature-extraction": TFDebertaVaModel,
				        "fill-mask": TFDebertaVaForMaskedLM,
				        "question-answering": TFDebertaVaForQuestionAnswering,
				        "text-classification": TFDebertaVaForSequenceClassification,
				        "token-classification": TFDebertaVaForTokenClassification,
				        "zero-shot": TFDebertaVaForSequenceClassification,
				    }
				    if is_tf_available()
				    else {}
				)

				SCREAMING_SNAKE_CASE_:							str							=					False
				SCREAMING_SNAKE_CASE_:							List[str]							=					False


				def 				__lowerCamelCase	(					self	:			Optional[int]  )		->  List[str]:







											"""simple docstring"""




											_lowerCAmelCase  	=			TFDebertaVaModelTester(self  )
											_lowerCAmelCase  	=			ConfigTester(self				,     config_class=UpperCAmelCase_				,     hidden_size=37  )


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







											"""simple docstring"""




											self.config_tester.run_common_tests()


				def 				__lowerCamelCase	(					self	:			Optional[int]  )		->  List[str]:







											"""simple docstring"""




											_lowerCAmelCase  	=			self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_model(*UpperCAmelCase_  )


				def 				__lowerCamelCase	(					self	:			List[Any]  )		->  Optional[int]:







											"""simple docstring"""




											_lowerCAmelCase  	=			self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_masked_lm(*UpperCAmelCase_  )


				def 				__lowerCamelCase	(					self	:			Dict  )		->  List[str]:







											"""simple docstring"""




											_lowerCAmelCase  	=			self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_question_answering(*UpperCAmelCase_  )


				def 				__lowerCamelCase	(					self	:			Any  )		->  int:







											"""simple docstring"""




											_lowerCAmelCase  	=			self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_sequence_classification(*UpperCAmelCase_  )


				def 				__lowerCamelCase	(					self	:			Tuple  )		->  Optional[int]:







											"""simple docstring"""




											_lowerCAmelCase  	=			self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_token_classification(*UpperCAmelCase_  )







				@slow
				def 				__lowerCamelCase	(					self	:			List[str]  )		->  List[Any]:







											"""simple docstring"""




											_lowerCAmelCase  	=			TFDebertaVaModel.from_pretrained('kamalkraj/deberta-v2-xlarge'  )
											self.assertIsNotNone(UpperCAmelCase_  )






@require_tf
class        _SCREAMING_SNAKE_CASE  (  unittest.TestCase							):






				'''simple docstring'''



				@unittest.skip(reason='Model not available yet'  )
				def 				__lowerCamelCase	(					self	:			Optional[Any]  )		->  Tuple:







											"""simple docstring"""




											pass







				@slow
				def 				__lowerCamelCase	(					self	:			Any  )		->  int:







											"""simple docstring"""




											_lowerCAmelCase  	=			TFDebertaVaModel.from_pretrained('kamalkraj/deberta-v2-xlarge'  )
											_lowerCAmelCase  	=			tf.constant([[0, 31_414, 232, 328, 740, 1_140, 12_695, 69, 46_078, 1_588, 2]]  )
											_lowerCAmelCase  	=			tf.constant([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]  )
											_lowerCAmelCase  	=			model(UpperCAmelCase_				,     attention_mask=UpperCAmelCase_  )[0]

											_lowerCAmelCase  	=			tf.constant(
											    [[[0.2356, 0.1948, 0.0369], [-0.1063, 0.3586, -0.5152], [-0.6399, -0.0259, -0.2525]]]  )
											tf.debugging.assert_near(output[:, 1:4, 1:4]				,     UpperCAmelCase_				,     atol=1E-4  )






