


"""simple docstring"""


import tempfile
import unittest

from transformers import DPRConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
		import torch

		from transformers import DPRContextEncoder, DPRQuestionEncoder, DPRReader, DPRReaderTokenizer
		from transformers.models.dpr.modeling_dpr import (
		    DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
		    DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
		    DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST,
		)
class snake_case   :







		def __init__(       self   :							Any     , a__   :							Optional[int]     , a__   :							List[str]=13     , a__   :							List[str]=7     , a__   :							Optional[Any]=False     , a__   :							str=True     , a__   :							Optional[Any]=True     , a__   :							Dict=True     , a__   :							Dict=99     , a__   :							Optional[Any]=32     , a__   :							Tuple=5     , a__   :							Any=4     , a__   :							str=37     , a__   :							Union[str, Any]="gelu"     , a__   :							Any=0.1     , a__   :							Dict=0.1     , a__   :							Optional[Any]=5_12     , a__   :							Dict=16     , a__   :							Optional[int]=2     , a__   :							int=0.0_2     , a__   :							Union[str, Any]=3     , a__   :							Optional[int]=4     , a__   :							int=None     , a__   :							Any=0     , )							->    List[str]:





						'''simple docstring'''







						_A       	=      parent
						_A       	=      batch_size
						_A       	=      seq_length
						_A       	=      is_training
						_A       	=      use_input_mask
						_A       	=      use_token_type_ids
						_A       	=      use_labels
						_A       	=      vocab_size
						_A       	=      hidden_size
						_A       	=      num_hidden_layers
						_A       	=      num_attention_heads
						_A       	=      intermediate_size
						_A       	=      hidden_act
						_A       	=      hidden_dropout_prob
						_A       	=      attention_probs_dropout_prob
						_A       	=      max_position_embeddings
						_A       	=      type_vocab_size
						_A       	=      type_sequence_label_size
						_A       	=      initializer_range
						_A       	=      num_labels
						_A       	=      num_choices
						_A       	=      scope
						_A       	=      projection_dim







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





						'''simple docstring'''







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

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

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

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

						_A       	=      self.get_config()

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







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





						'''simple docstring'''







						return DPRConfig(
						    projection_dim=self.projection_dim     , 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     , initializer_range=self.initializer_range     , )







		def 			a_			(       self   :							Optional[int]     , a__   :							Any     , a__   :							Optional[int]     , a__   :							Union[str, Any]     , a__   :							List[str]     , a__   :							int     , a__   :							Tuple     , a__   :							List[Any]		)							->    List[Any]:





						'''simple docstring'''







						_A       	=      DPRContextEncoder(config=a__		)
						model.to(a__		)
						model.eval()
						_A       	=      model(a__     , attention_mask=a__     , token_type_ids=a__		)
						_A       	=      model(a__     , token_type_ids=a__		)
						_A       	=      model(a__		)
						self.parent.assertEqual(result.pooler_output.shape     , (self.batch_size, self.projection_dim or self.hidden_size)		)







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





						'''simple docstring'''







						_A       	=      DPRQuestionEncoder(config=a__		)
						model.to(a__		)
						model.eval()
						_A       	=      model(a__     , attention_mask=a__     , token_type_ids=a__		)
						_A       	=      model(a__     , token_type_ids=a__		)
						_A       	=      model(a__		)
						self.parent.assertEqual(result.pooler_output.shape     , (self.batch_size, self.projection_dim or self.hidden_size)		)







		def 			a_			(       self   :							Optional[Any]     , a__   :							Optional[int]     , a__   :							Optional[int]     , a__   :							Union[str, Any]     , a__   :							Dict     , a__   :							Any     , a__   :							Tuple     , a__   :							Any		)							->    Optional[int]:





						'''simple docstring'''







						_A       	=      DPRReader(config=a__		)
						model.to(a__		)
						model.eval()
						_A       	=      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 			a_			(       self   :							List[Any]		)							->    Tuple:





						'''simple docstring'''







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





@require_torch
class snake_case   (	_UpperCamelCase  ,					_UpperCamelCase  ,					unittest.TestCase):
		__UpperCamelCase							     =      (
		    (
		        DPRContextEncoder,
		        DPRQuestionEncoder,
		        DPRReader,
		    )
		    if is_torch_available()
		    else ()
		)
		__UpperCamelCase							     =      {'feature-extraction': DPRQuestionEncoder} if is_torch_available() else {}

		__UpperCamelCase							     =      False
		__UpperCamelCase							     =      False  # why?
		__UpperCamelCase							     =      False
		__UpperCamelCase							     =      False







		def 			a_			(       self   :							Optional[int]		)							->    Union[str, Any]:





						'''simple docstring'''







						_A       	=      DPRModelTester(self		)
						_A       	=      ConfigTester(self     , config_class=a__     , hidden_size=37		)







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





						'''simple docstring'''







						self.config_tester.run_common_tests()







		def 			a_			(       self   :							Dict		)							->    List[Any]:





						'''simple docstring'''







						_A       	=      self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_context_encoder(*a__		)







		def 			a_			(       self   :							str		)							->    Any:





						'''simple docstring'''







						_A       	=      self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_question_encoder(*a__		)







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





						'''simple docstring'''







						_A       	=      self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_reader(*a__		)







		def 			a_			(       self   :							List[str]		)							->    str:





						'''simple docstring'''







						_A       	=      self.model_tester.prepare_config_and_inputs()[0]

						_A       	=      DPRQuestionEncoder(config=a__		)
						model.to(a__		)
						model.eval()

						with tempfile.TemporaryDirectory() as tmp_dirname:
										model.save_pretrained(a__		)
										_A       	=      DPRQuestionEncoder.from_pretrained(a__     , projection_dim=5_12		)

						self.assertIsNotNone(a__		)







		@slow
		def 			a_			(       self   :							Union[str, Any]		)							->    Tuple:





						'''simple docstring'''







						for model_name in DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
										_A       	=      DPRContextEncoder.from_pretrained(a__		)
										self.assertIsNotNone(a__		)

						for model_name in DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
										_A       	=      DPRContextEncoder.from_pretrained(a__		)
										self.assertIsNotNone(a__		)

						for model_name in DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
										_A       	=      DPRQuestionEncoder.from_pretrained(a__		)
										self.assertIsNotNone(a__		)

						for model_name in DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
										_A       	=      DPRReader.from_pretrained(a__		)
										self.assertIsNotNone(a__		)





@require_torch
class snake_case   (	unittest.TestCase):







		@slow
		def 			a_			(       self   :							List[str]		)							->    Tuple:





						'''simple docstring'''







						_A       	=      DPRQuestionEncoder.from_pretrained("facebook/dpr-question_encoder-single-nq-base"     , return_dict=a__		)
						model.to(a__		)

						_A       	=      torch.tensor(
						    [[1_01, 75_92, 10_10, 20_03, 20_26, 38_99, 1_01_40, 10_29, 1_02]]     , dtype=torch.long     , device=a__		)  # [CLS] hello, is my dog cute? [SEP]
						_A       	=      model(a__		)[0]  # embedding shape = (1, 768)
						# compare the actual values for a slice.
						_A       	=      torch.tensor(
						    [
						        [
						            0.0_3_2_3_6_2_5_3,
						            0.1_2_7_5_3_3_3_5,
						            0.1_6_8_1_8_5_0_9,
						            0.0_0_2_7_9_7_8_6,
						            0.3_8_9_6_9_3_3,
						            0.2_4_2_6_4_9_4_5,
						            0.2_1_7_8_9_7_1,
						            -0.0_2_3_3_5_2_2_7,
						            -0.0_8_4_8_1_9_5_9,
						            -0.1_4_3_2_4_1_1_7,
						        ]
						    ]     , dtype=torch.float     , device=a__     , )
						self.assertTrue(torch.allclose(output[:, :10]     , a__     , atol=1E-4		)		)







		@slow
		def 			a_			(       self   :							Tuple		)							->    Optional[Any]:





						'''simple docstring'''







						_A       	=      DPRReaderTokenizer.from_pretrained("facebook/dpr-reader-single-nq-base"		)
						_A       	=      DPRReader.from_pretrained("facebook/dpr-reader-single-nq-base"		)
						model.to(a__		)

						_A       	=      tokenizer(
						    questions="What is love ?"     , titles="Haddaway"     , texts="What Is Love is a song recorded by the artist Haddaway"     , padding=a__     , return_tensors="pt"     , )
						encoded_inputs.to(a__		)

						_A       	=      model(**a__		)

						# compare the actual values for a slice.
						_A       	=      torch.tensor(
						    [[-1_0.3_0_0_5, -1_0.7_7_6_5, -1_1.4_8_7_2, -1_1.6_8_4_1, -1_1.9_3_1_2, -1_0.3_0_0_2, -9.8_5_4_4, -1_1.7_3_7_8, -1_2.0_8_2_1, -1_0.2_9_7_5]]     , dtype=torch.float     , device=a__     , )

						_A       	=      torch.tensor(
						    [[-1_1.0_6_8_4, -1_1.7_0_4_1, -1_1.5_3_9_7, -1_0.3_4_6_5, -1_0.8_7_9_1, -6.8_4_4_3, -1_1.9_9_5_9, -1_1.0_3_6_4, -1_0.0_0_9_6, -6.8_4_0_5]]     , dtype=torch.float     , device=a__     , )
						self.assertTrue(torch.allclose(outputs.start_logits[:, :10]     , a__     , atol=1E-4		)		)
						self.assertTrue(torch.allclose(outputs.end_logits[:, :10]     , a__     , atol=1E-4		)		)



"""simple docstring"""


from math import factorial






def   a__			(					__lowercase  ,      __lowercase )						->						List[Any]:
				return factorial(__lowercase ) / (factorial(__lowercase ) * factorial(n - r ))






def   a__			(					)						->						List[str]:
				_A       	=      0

				for i in range(1  ,      101 ):
								for j in range(1  ,      i + 1 ):
												if combinations(__lowercase  ,      __lowercase ) > 1E6:
																total += 1
				return total


if __name__ == "__main__":
		print(solution())