'''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        SCREAMING_SNAKE_CASE   :
  """simple docstring"""







  def __init__(  self   :					List[str]					,					__lowerCAmelCase   :					Tuple					,					__lowerCAmelCase   :					List[Any]=13					,					__lowerCAmelCase   :					Union[str, Any]=7					,					__lowerCAmelCase   :					Tuple=False					,					__lowerCAmelCase   :					Dict=True					,					__lowerCAmelCase   :					Optional[int]=True					,					__lowerCAmelCase   :					Optional[Any]=True					,					__lowerCAmelCase   :					Optional[int]=99					,					__lowerCAmelCase   :					Optional[Any]=32					,					__lowerCAmelCase   :					Tuple=5					,					__lowerCAmelCase   :					List[Any]=4					,					__lowerCAmelCase   :					int=37					,					__lowerCAmelCase   :					Dict="gelu"					,					__lowerCAmelCase   :					Tuple=0.1					,					__lowerCAmelCase   :					Tuple=0.1					,					__lowerCAmelCase   :					Tuple=512					,					__lowerCAmelCase   :					Optional[int]=16					,					__lowerCAmelCase   :					int=2					,					__lowerCAmelCase   :					Tuple=0.0_2					,					__lowerCAmelCase   :					Optional[int]=3					,					__lowerCAmelCase   :					str=4					,					__lowerCAmelCase   :					List[Any]=None					,					__lowerCAmelCase   :					Optional[Any]=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   a   (  self   :					List[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		   =   ids_tensor([self.batch_size]					,					self.num_choices					)

        _lowerCAmelCase		   =   self.get_config()

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



  def   a   (  self   :					List[str]					):


        """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[Any]					,					__lowerCAmelCase   :					Any					,					__lowerCAmelCase   :					int					,					__lowerCAmelCase   :					Optional[int]					,					__lowerCAmelCase   :					Optional[int]					,					__lowerCAmelCase   :					List[str]					,					__lowerCAmelCase   :					Tuple					,					__lowerCAmelCase   :					int					):


        """simple docstring"""



        _lowerCAmelCase		   =   DPRContextEncoder(config=_A					)
        model.to(_A					)
        model.eval()
        _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   a   (  self   :					Optional[int]					,					__lowerCAmelCase   :					Any					,					__lowerCAmelCase   :					Union[str, Any]					,					__lowerCAmelCase   :					List[Any]					,					__lowerCAmelCase   :					str					,					__lowerCAmelCase   :					Tuple					,					__lowerCAmelCase   :					Optional[Any]					,					__lowerCAmelCase   :					Tuple					):


        """simple docstring"""



        _lowerCAmelCase		   =   DPRQuestionEncoder(config=_A					)
        model.to(_A					)
        model.eval()
        _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   a   (  self   :					Tuple					,					__lowerCAmelCase   :					List[str]					,					__lowerCAmelCase   :					Tuple					,					__lowerCAmelCase   :					Optional[Any]					,					__lowerCAmelCase   :					Union[str, Any]					,					__lowerCAmelCase   :					Any					,					__lowerCAmelCase   :					Dict					,					__lowerCAmelCase   :					Union[str, Any]					):


        """simple docstring"""



        _lowerCAmelCase		   =   DPRReader(config=_A					)
        model.to(_A					)
        model.eval()
        _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   a   (  self   :					int					):


        """simple docstring"""



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





@require_torch
class        SCREAMING_SNAKE_CASE   (				lowercase__	,						lowercase__	,						unittest.TestCase ):
  """simple docstring"""







  __A     =		(
      (
          DPRContextEncoder,
          DPRQuestionEncoder,
          DPRReader,
      )
      if is_torch_available()
      else ()
  )
  __A     =		{"""feature-extraction""": DPRQuestionEncoder} if is_torch_available() else {}

  __A     =		False
  __A     =		False  # why?
  __A     =		False
  __A     =		False



  def   a   (  self   :					Dict					):


        """simple docstring"""



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



  def   a   (  self   :					List[Any]					):


        """simple docstring"""



        self.config_tester.run_common_tests()



  def   a   (  self   :					Tuple					):


        """simple docstring"""



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



  def   a   (  self   :					List[Any]					):


        """simple docstring"""



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



  def   a   (  self   :					Tuple					):


        """simple docstring"""



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



  def   a   (  self   :					Union[str, Any]					):


        """simple docstring"""



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

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

        with tempfile.TemporaryDirectory() as tmp_dirname:
              model.save_pretrained(_A					)
              _lowerCAmelCase		   =   DPRQuestionEncoder.from_pretrained(_A					,					projection_dim=512					)

        self.assertIsNotNone(_A					)



  @slow
  def   a   (  self   :					Dict					):


        """simple docstring"""



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

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

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

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





@require_torch
class        SCREAMING_SNAKE_CASE   (				unittest.TestCase ):
  """simple docstring"""







  @slow
  def   a   (  self   :					Tuple					):


        """simple docstring"""



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

        _lowerCAmelCase		   =   torch.tensor(
            [[101, 7592, 1010, 2003, 2026, 3899, 1_0140, 1029, 102]]					,					dtype=torch.long					,					device=_A					)  # [CLS] hello, is my dog cute? [SEP]
        _lowerCAmelCase		   =   model(_A					)[0]  # embedding shape = (1, 768)
        # compare the actual values for a slice.
        _lowerCAmelCase		   =   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   :					List[Any]					):


        """simple docstring"""



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

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

        _lowerCAmelCase		   =   model(**_A					)

        # compare the actual values for a slice.
        _lowerCAmelCase		   =   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					,					)

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




import itertools







def 			A_   ( _lowerCamelCase			:							Tuple    ):
      return (
          int(''.join(combination[0:2]    )    ) * int(''.join(combination[2:5]    )    )
          == int(''.join(combination[5:9]    )    )
      ) or (
          int(''.join(combination[0]    )    ) * int(''.join(combination[1:5]    )    )
          == int(''.join(combination[5:9]    )    )
      )







def 			A_   ( ):
      return sum(
          {
              int(''.join(pandigital[5:9]    )    )
              for pandigital in itertools.permutations('123456789'    )
              if is_combination_valid(_lowerCamelCase    )
          }    )


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





