




"""simple docstring"""




from __future__ import annotations

import unittest

from transformers import 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 numpy
					import tensorflow as tf

					from transformers import (
					    TF_DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
					    TF_DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
					    TF_DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST,
					    BertConfig,
					    DPRConfig,
					    TFDPRContextEncoder,
					    TFDPRQuestionEncoder,
					    TFDPRReader,
					)






class     __magic_name__							:






				'''simple docstring'''





				def __init__(       self		, _a		, _a=13		, _a=7		, _a=True		, _a=True		, _a=True		, _a=True		, _a=99		, _a=32		, _a=2		, _a=4		, _a=37		, _a="gelu"		, _a=0.1		, _a=0.1		, _a=512		, _a=16		, _a=2		, _a=0.02		, _a=3		, _a=4		, _a=None		, _a=0		, ):





							"""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			      =					scope
							lowerCamelCase			      =					projection_dim





				def    _lowerCAmelCase				(       self ):





							"""simple docstring"""
							lowerCamelCase			      =					ids_tensor([self.batch_size, self.seq_length]		, self.vocab_size )

							lowerCamelCase			      =					None
							if self.use_input_mask:
										# follow test_modeling_tf_ctrl.py
										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			      =					ids_tensor([self.batch_size]		, self.num_choices )

							lowerCamelCase			      =					BertConfig(
							    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		, is_decoder=A__		, initializer_range=self.initializer_range		, )
							lowerCamelCase			      =					DPRConfig(projection_dim=self.projection_dim		, **config.to_dict() )

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





				def    _lowerCAmelCase				(       self		, _a		, _a		, _a		, _a		, _a		, _a		, _a ):





							"""simple docstring"""
							lowerCamelCase			      =					TFDPRContextEncoder(config=A__ )
							lowerCamelCase			      =					model(A__		, attention_mask=A__		, token_type_ids=A__ )
							lowerCamelCase			      =					model(A__		, token_type_ids=A__ )
							lowerCamelCase			      =					model(A__ )
							self.parent.assertEqual(result.pooler_output.shape		, (self.batch_size, self.projection_dim or self.hidden_size) )





				def    _lowerCAmelCase				(       self		, _a		, _a		, _a		, _a		, _a		, _a		, _a ):





							"""simple docstring"""
							lowerCamelCase			      =					TFDPRQuestionEncoder(config=A__ )
							lowerCamelCase			      =					model(A__		, attention_mask=A__		, token_type_ids=A__ )
							lowerCamelCase			      =					model(A__		, token_type_ids=A__ )
							lowerCamelCase			      =					model(A__ )
							self.parent.assertEqual(result.pooler_output.shape		, (self.batch_size, self.projection_dim or self.hidden_size) )





				def    _lowerCAmelCase				(       self		, _a		, _a		, _a		, _a		, _a		, _a		, _a ):





							"""simple docstring"""
							lowerCamelCase			      =					TFDPRReader(config=A__ )
							lowerCamelCase			      =					model(A__		, attention_mask=A__ )

							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) )
							self.parent.assertEqual(result.relevance_logits.shape		, (self.batch_size,) )





				def    _lowerCAmelCase				(       self ):





							"""simple docstring"""
							lowerCamelCase			      =					self.prepare_config_and_inputs()
							(
							    lowerCamelCase   
							)			      =					config_and_inputs
							lowerCamelCase			      =					{"""input_ids""": input_ids}
							return config, inputs_dict






@require_tf
class     __magic_name__							(       UpperCAmelCase__						,					UpperCAmelCase__						,					unittest.TestCase				):






				'''simple docstring'''
				__UpperCamelCase			  =						(
				    (
				        TFDPRContextEncoder,
				        TFDPRQuestionEncoder,
				        TFDPRReader,
				    )
				    if is_tf_available()
				    else ()
				)
				__UpperCamelCase			  =						{'''feature-extraction''': TFDPRQuestionEncoder} if is_tf_available() else {}

				__UpperCamelCase			  =						False
				__UpperCamelCase			  =						False
				__UpperCamelCase			  =						False
				__UpperCamelCase			  =						False
				__UpperCamelCase			  =						False





				def    _lowerCAmelCase				(       self ):





							"""simple docstring"""
							lowerCamelCase			      =					TFDPRModelTester(self )
							lowerCamelCase			      =					ConfigTester(self		, config_class=A__		, hidden_size=37 )





				def    _lowerCAmelCase				(       self ):





							"""simple docstring"""
							self.config_tester.run_common_tests()





				def    _lowerCAmelCase				(       self ):





							"""simple docstring"""
							lowerCamelCase			      =					self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_dpr_context_encoder(*A__ )





				def    _lowerCAmelCase				(       self ):





							"""simple docstring"""
							lowerCamelCase			      =					self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_dpr_question_encoder(*A__ )





				def    _lowerCAmelCase				(       self ):





							"""simple docstring"""
							lowerCamelCase			      =					self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_dpr_reader(*A__ )





				@slow
				def    _lowerCAmelCase				(       self ):





							"""simple docstring"""
							for model_name in TF_DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
										lowerCamelCase			      =					TFDPRContextEncoder.from_pretrained(A__ )
										self.assertIsNotNone(A__ )

							for model_name in TF_DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
										lowerCamelCase			      =					TFDPRContextEncoder.from_pretrained(A__ )
										self.assertIsNotNone(A__ )

							for model_name in TF_DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
										lowerCamelCase			      =					TFDPRQuestionEncoder.from_pretrained(A__ )
										self.assertIsNotNone(A__ )

							for model_name in TF_DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
										lowerCamelCase			      =					TFDPRReader.from_pretrained(A__ )
										self.assertIsNotNone(A__ )






@require_tf
class     __magic_name__							(       unittest.TestCase				):






				'''simple docstring'''





				@slow
				def    _lowerCAmelCase				(       self ):





							"""simple docstring"""
							lowerCamelCase			      =					TFDPRQuestionEncoder.from_pretrained("""facebook/dpr-question_encoder-single-nq-base""" )

							lowerCamelCase			      =					tf.constant(
							    [[101, 7_592, 1_010, 2_003, 2_026, 3_899, 10_140, 1_029, 102]] )  # [CLS] hello, is my dog cute? [SEP]
							lowerCamelCase			      =					model(A__ )[0]  # embedding shape = (1, 768)
							# compare the actual values for a slice.
							lowerCamelCase			      =					tf.constant(
							    [
							        [
							            0.03_236_253,
							            0.12_753_335,
							            0.16_818_509,
							            0.00_279_786,
							            0.3_896_933,
							            0.24_264_945,
							            0.2_178_971,
							            -0.02_335_227,
							            -0.08_481_959,
							            -0.14_324_117,
							        ]
							    ] )
							self.assertTrue(numpy.allclose(output[:, :10].numpy()		, expected_slice.numpy()		, atol=1e-4 ) )






from math import factorial

def 						UpperCamelCase					(lowercase_: int = 20					)     ->      int:
	A__							:    Union[str, Any]        =		2 * n  # middle entry of odd rows starting at row 3 is the solution for n = 1,
	# 2, 3,...
	A__							:    Tuple        =		n // 2

	return int(factorial(lowercase_					) / (factorial(lowercase_					) * factorial(n - k					))					)


if __name__ == "__main__":
	import sys

	if len(sys.argv) == 1:
		print(solution(20))
	else:
		try:
			A_       : List[str]         =			int(sys.argv[1])
			print(solution(n))
		except ValueError:
			print('Invalid entry - please enter a number.')



