






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 	a_:



     """simple docstring"""



     def __init__(		self					:	Tuple  ,  lowerCAmelCase__					:	Union[str, Any]  ,  lowerCAmelCase__					:	int=1_3  ,  lowerCAmelCase__					:	Optional[int]=7  ,  lowerCAmelCase__					:	Union[str, Any]=False  ,  lowerCAmelCase__					:	int=True  ,  lowerCAmelCase__					:	Dict=True  ,  lowerCAmelCase__					:	Dict=True  ,  lowerCAmelCase__					:	Any=9_9  ,  lowerCAmelCase__					:	Optional[Any]=3_2  ,  lowerCAmelCase__					:	str=5  ,  lowerCAmelCase__					:	Tuple=4  ,  lowerCAmelCase__					:	List[str]=3_7  ,  lowerCAmelCase__					:	Optional[int]="gelu"  ,  lowerCAmelCase__					:	Optional[Any]=0.1  ,  lowerCAmelCase__					:	List[str]=0.1  ,  lowerCAmelCase__					:	List[str]=5_1_2  ,  lowerCAmelCase__					:	Optional[int]=1_6  ,  lowerCAmelCase__					:	Any=2  ,  lowerCAmelCase__					:	List[str]=0.02  ,  lowerCAmelCase__					:	int=3  ,  lowerCAmelCase__					:	str=4  ,  lowerCAmelCase__					:	Any=None  ,  lowerCAmelCase__					:	Dict=0  ,  )							->	List[Any]:

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





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

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

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

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

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

      SCREAMING_SNAKE_CASE				    =		self.get_config()

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





     def     __UpperCamelCase						(		self					:	List[str])							->	Optional[Any]:

      """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     __UpperCamelCase						(		self					:	Tuple  ,  lowerCAmelCase__					:	List[Any]  ,  lowerCAmelCase__					:	List[str]  ,  lowerCAmelCase__					:	List[str]  ,  lowerCAmelCase__					:	int  ,  lowerCAmelCase__					:	str  ,  lowerCAmelCase__					:	Dict  ,  lowerCAmelCase__					:	str)							->	Any:

      """simple docstring"""
      SCREAMING_SNAKE_CASE				    =		DPRContextEncoder(config=lowerCAmelCase__)
      model.to(lowerCAmelCase__)
      model.eval()
      SCREAMING_SNAKE_CASE				    =		model(lowerCAmelCase__  ,  attention_mask=lowerCAmelCase__  ,  token_type_ids=lowerCAmelCase__)
      SCREAMING_SNAKE_CASE				    =		model(lowerCAmelCase__  ,  token_type_ids=lowerCAmelCase__)
      SCREAMING_SNAKE_CASE				    =		model(lowerCAmelCase__)
      self.parent.assertEqual(result.pooler_output.shape  ,  (self.batch_size, self.projection_dim or self.hidden_size))





     def     __UpperCamelCase						(		self					:	Optional[Any]  ,  lowerCAmelCase__					:	Optional[Any]  ,  lowerCAmelCase__					:	Optional[int]  ,  lowerCAmelCase__					:	str  ,  lowerCAmelCase__					:	Any  ,  lowerCAmelCase__					:	Dict  ,  lowerCAmelCase__					:	Tuple  ,  lowerCAmelCase__					:	List[str])							->	List[str]:

      """simple docstring"""
      SCREAMING_SNAKE_CASE				    =		DPRQuestionEncoder(config=lowerCAmelCase__)
      model.to(lowerCAmelCase__)
      model.eval()
      SCREAMING_SNAKE_CASE				    =		model(lowerCAmelCase__  ,  attention_mask=lowerCAmelCase__  ,  token_type_ids=lowerCAmelCase__)
      SCREAMING_SNAKE_CASE				    =		model(lowerCAmelCase__  ,  token_type_ids=lowerCAmelCase__)
      SCREAMING_SNAKE_CASE				    =		model(lowerCAmelCase__)
      self.parent.assertEqual(result.pooler_output.shape  ,  (self.batch_size, self.projection_dim or self.hidden_size))





     def     __UpperCamelCase						(		self					:	str  ,  lowerCAmelCase__					:	Any  ,  lowerCAmelCase__					:	Optional[int]  ,  lowerCAmelCase__					:	Optional[int]  ,  lowerCAmelCase__					:	Dict  ,  lowerCAmelCase__					:	List[str]  ,  lowerCAmelCase__					:	int  ,  lowerCAmelCase__					:	Tuple)							->	Tuple:

      """simple docstring"""
      SCREAMING_SNAKE_CASE				    =		DPRReader(config=lowerCAmelCase__)
      model.to(lowerCAmelCase__)
      model.eval()
      SCREAMING_SNAKE_CASE				    =		model(
          lowerCAmelCase__  ,  attention_mask=lowerCAmelCase__  ,  )

      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     __UpperCamelCase						(		self					:	Any)							->	Dict:

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

@require_torch
class 	a_(		lowercase__			,							lowercase__			,							unittest.TestCase	):



     """simple docstring"""



     __snake_case		:				Union[str, Any]  					=(
         (
             DPRContextEncoder,
             DPRQuestionEncoder,
             DPRReader,
         )
         if is_torch_available()
         else ()
     )
     __snake_case		:				Union[str, Any]  					={'''feature-extraction''': DPRQuestionEncoder} if is_torch_available() else {}

     __snake_case		:				List[str]  					=False
     __snake_case		:				Tuple  					=False  # why?
     __snake_case		:				Tuple  					=False
     __snake_case		:				Optional[Any]  					=False





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

      """simple docstring"""
      SCREAMING_SNAKE_CASE				    =		DPRModelTester(self)
      SCREAMING_SNAKE_CASE				    =		ConfigTester(self  ,  config_class=lowerCAmelCase__  ,  hidden_size=3_7)





     def     __UpperCamelCase						(		self					:	Tuple)							->	List[Any]:

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





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

      """simple docstring"""
      SCREAMING_SNAKE_CASE				    =		self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_context_encoder(*lowerCAmelCase__)





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

      """simple docstring"""
      SCREAMING_SNAKE_CASE				    =		self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_question_encoder(*lowerCAmelCase__)





     def     __UpperCamelCase						(		self					:	str)							->	Optional[Any]:

      """simple docstring"""
      SCREAMING_SNAKE_CASE				    =		self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_reader(*lowerCAmelCase__)





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

      """simple docstring"""
      SCREAMING_SNAKE_CASE				    =		self.model_tester.prepare_config_and_inputs()[0]

      SCREAMING_SNAKE_CASE				    =		DPRQuestionEncoder(config=lowerCAmelCase__)
      model.to(lowerCAmelCase__)
      model.eval()

      with tempfile.TemporaryDirectory() as tmp_dirname:
       model.save_pretrained(lowerCAmelCase__)
       SCREAMING_SNAKE_CASE				    =		DPRQuestionEncoder.from_pretrained(lowerCAmelCase__  ,  projection_dim=5_1_2)

      self.assertIsNotNone(lowerCAmelCase__)





     @slow
     def     __UpperCamelCase						(		self					:	int)							->	Dict:

      """simple docstring"""
      for model_name in DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
       SCREAMING_SNAKE_CASE				    =		DPRContextEncoder.from_pretrained(lowerCAmelCase__)
       self.assertIsNotNone(lowerCAmelCase__)

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

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

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

@require_torch
class 	a_(		unittest.TestCase	):



     """simple docstring"""



     @slow
     def     __UpperCamelCase						(		self					:	List[Any])							->	Dict:

      """simple docstring"""
      SCREAMING_SNAKE_CASE				    =		DPRQuestionEncoder.from_pretrained('facebook/dpr-question_encoder-single-nq-base'  ,  return_dict=lowerCAmelCase__)
      model.to(lowerCAmelCase__)

      SCREAMING_SNAKE_CASE				    =		torch.tensor(
          [[1_0_1, 7_5_9_2, 1_0_1_0, 2_0_0_3, 2_0_2_6, 3_8_9_9, 1_0_1_4_0, 1_0_2_9, 1_0_2]]  ,  dtype=torch.long  ,  device=lowerCAmelCase__)  # [CLS] hello, is my dog cute? [SEP]
      SCREAMING_SNAKE_CASE				    =		model(lowerCAmelCase__)[0]  # embedding shape = (1, 768)
      # compare the actual values for a slice.
      SCREAMING_SNAKE_CASE				    =		torch.tensor(
          [
              [
                  0.03_23_62_53,
                  0.12_75_33_35,
                  0.16_81_85_09,
                  0.00_27_97_86,
                  0.3_89_69_33,
                  0.24_26_49_45,
                  0.2_17_89_71,
                  -0.02_33_52_27,
                  -0.08_48_19_59,
                  -0.14_32_41_17,
              ]
          ]  ,  dtype=torch.float  ,  device=lowerCAmelCase__  ,  )
      self.assertTrue(torch.allclose(output[:, :1_0]  ,  lowerCAmelCase__  ,  atol=1e-4))





     @slow
     def     __UpperCamelCase						(		self					:	int)							->	Optional[Any]:

      """simple docstring"""
      SCREAMING_SNAKE_CASE				    =		DPRReaderTokenizer.from_pretrained('facebook/dpr-reader-single-nq-base')
      SCREAMING_SNAKE_CASE				    =		DPRReader.from_pretrained('facebook/dpr-reader-single-nq-base')
      model.to(lowerCAmelCase__)

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

      SCREAMING_SNAKE_CASE				    =		model(**lowerCAmelCase__)

      # compare the actual values for a slice.
      SCREAMING_SNAKE_CASE				    =		torch.tensor(
          [[-10.30_05, -10.77_65, -11.48_72, -11.68_41, -11.93_12, -10.30_02, -9.85_44, -11.73_78, -12.08_21, -10.29_75]]  ,  dtype=torch.float  ,  device=lowerCAmelCase__  ,  )

      SCREAMING_SNAKE_CASE				    =		torch.tensor(
          [[-11.06_84, -11.70_41, -11.53_97, -10.34_65, -10.87_91, -6.84_43, -11.99_59, -11.03_64, -10.00_96, -6.84_05]]  ,  dtype=torch.float  ,  device=lowerCAmelCase__  ,  )
      self.assertTrue(torch.allclose(outputs.start_logits[:, :1_0]  ,  lowerCAmelCase__  ,  atol=1e-4))
      self.assertTrue(torch.allclose(outputs.end_logits[:, :1_0]  ,  lowerCAmelCase__  ,  atol=1e-4))






from __future__ import annotations

import os





class 						__lowercase:


       """simple docstring"""







       UpperCamelCase_				 =							(
           '''High card''',
           '''One pair''',
           '''Two pairs''',
           '''Three of a kind''',
           '''Straight''',
           '''Flush''',
           '''Full house''',
           '''Four of a kind''',
           '''Straight flush''',
           '''Royal flush''',
       )

       UpperCamelCase_				 =							(
           '''''',  # placeholder as tuples are zero-indexed
           '''One''',
           '''Two''',
           '''Three''',
           '''Four''',
           '''Five''',
           '''Six''',
           '''Seven''',
           '''Eight''',
           '''Nine''',
           '''Ten''',
           '''Jack''',
           '''Queen''',
           '''King''',
           '''Ace''',
       )



       def __init__(     self					:			Dict  ,      _lowerCAmelCase					:			str       )					->   None:
         if not isinstance(_lowerCAmelCase  ,      _lowerCAmelCase       ):
           _lowerCAmelCase						=		F'''Hand should be of type \'str\': {hand!r}'''
           raise TypeError(_lowerCAmelCase       )
         # split removes duplicate whitespaces so no need of strip
         if len(hand.split(' '       )       ) != 5:
           _lowerCAmelCase						=		F'''Hand should contain only 5 cards: {hand!r}'''
           raise ValueError(_lowerCAmelCase       )
         _lowerCAmelCase						=		hand
         _lowerCAmelCase						=		0
         _lowerCAmelCase						=		0
         _lowerCAmelCase	,       _lowerCAmelCase						=		self._internal_state()
         _lowerCAmelCase						=		self._get_hand_type()
         _lowerCAmelCase						=		self._card_values[0]



       @property
       def SCREAMING_SNAKE_CASE_				(     self					:			Any       )					->   List[Any]:
         return self._hand



       def SCREAMING_SNAKE_CASE_				(     self					:			int  ,      _lowerCAmelCase					:			PokerHand       )					->   str:
         # Breaking the tie works on the following order of precedence:
         # 1. First pair (default 0)
         # 2. Second pair (default 0)
         # 3. Compare all cards in reverse order because they are sorted.

         # First pair and second pair will only be a non-zero value if the card
         # type is either from the following:
         # 21: Four of a kind
         # 20: Full house
         # 17: Three of a kind
         # 16: Two pairs
         # 15: One pair
         if self._hand_type > other._hand_type:
           return "Win"
         elif self._hand_type < other._hand_type:
           return "Loss"
         elif self._first_pair == other._first_pair:
           if self._second_pair == other._second_pair:
             return self._compare_cards(_lowerCAmelCase       )
           else:
             return "Win" if self._second_pair > other._second_pair else "Loss"
         return "Win" if self._first_pair > other._first_pair else "Loss"



       def SCREAMING_SNAKE_CASE_				(     self					:			str       )					->   str:
         _lowerCAmelCase						=		PokerHand._HAND_NAME[self._hand_type - 14]
         _lowerCAmelCase						=		PokerHand._CARD_NAME[self._high_card]
         _lowerCAmelCase						=		PokerHand._CARD_NAME[self._first_pair]
         _lowerCAmelCase						=		PokerHand._CARD_NAME[self._second_pair]
         if self._hand_type in [22, 19, 18]:
           return name + F''', {high}-high'''
         elif self._hand_type in [21, 17, 15]:
           return name + F''', {paira}s'''
         elif self._hand_type in [20, 16]:
           _lowerCAmelCase						=		'over' if self._hand_type == 20 else 'and'
           return name + F''', {paira}s {join} {paira}s'''
         elif self._hand_type == 23:
           return name
         else:
           return name + F''', {high}'''



       def SCREAMING_SNAKE_CASE_				(     self					:			Any  ,      _lowerCAmelCase					:			PokerHand       )					->   str:
         # Enumerate gives us the index as well as the element of a list
         for index, card_value in enumerate(self._card_values       ):
           if card_value != other._card_values[index]:
             return "Win" if card_value > other._card_values[index] else "Loss"
         return "Tie"



       def SCREAMING_SNAKE_CASE_				(     self					:			Optional[Any]       )					->   int:
         # Number representing the type of hand internally:
         # 23: Royal flush
         # 22: Straight flush
         # 21: Four of a kind
         # 20: Full house
         # 19: Flush
         # 18: Straight
         # 17: Three of a kind
         # 16: Two pairs
         # 15: One pair
         # 14: High card
         if self._is_flush():
           if self._is_five_high_straight() or self._is_straight():
             return 23 if sum(self._card_values       ) == 60 else 22
           return 19
         elif self._is_five_high_straight() or self._is_straight():
           return 18
         return 14 + self._is_same_kind()



       def SCREAMING_SNAKE_CASE_				(     self					:			Any       )					->   bool:
         return len(self._card_suit       ) == 1



       def SCREAMING_SNAKE_CASE_				(     self					:			str       )					->   bool:
         # If a card is a five high straight (low ace) change the location of
         # ace from the start of the list to the end. Check whether the first
         # element is ace or not. (Don't want to change again)
         # Five high straight (low ace): AH 2H 3S 4C 5D
         # Why use sorted here? One call to this function will mutate the list to
         # [5, 4, 3, 2, 14] and so for subsequent calls (which will be rare) we
         # need to compare the sorted version.
         # Refer test_multiple_calls_five_high_straight in test_poker_hand.py
         if sorted(self._card_values       ) == [2, 3, 4, 5, 14]:
           if self._card_values[0] == 14:
             # Remember, our list is sorted in reverse order
             _lowerCAmelCase						=		self._card_values.pop(0       )
             self._card_values.append(_lowerCAmelCase       )
           return True
         return False



       def SCREAMING_SNAKE_CASE_				(     self					:			Optional[Any]       )					->   bool:
         for i in range(4       ):
           if self._card_values[i] - self._card_values[i + 1] != 1:
             return False
         return True



       def SCREAMING_SNAKE_CASE_				(     self					:			Dict       )					->   int:
         # Kind Values for internal use:
         # 7: Four of a kind
         # 6: Full house
         # 3: Three of a kind
         # 2: Two pairs
         # 1: One pair
         # 0: False
         _lowerCAmelCase						=		_lowerCAmelCase						=		_lowerCAmelCase						=		0
         for i in range(4       ):
           # Compare two cards at a time, if they are same increase 'kind',
           # add the value of the card to val1, if it is repeating again we
           # will add 2 to 'kind' as there are now 3 cards with same value.
           # If we get card of different value than val1, we will do the same
           # thing with val2
           if self._card_values[i] == self._card_values[i + 1]:
             if not vala:
               _lowerCAmelCase						=		self._card_values[i]
               kind += 1
             elif vala == self._card_values[i]:
               kind += 2
             elif not vala:
               _lowerCAmelCase						=		self._card_values[i]
               kind += 1
             elif vala == self._card_values[i]:
               kind += 2
        # For consistency in hand type (look at note in _get_hand_type function)
         _lowerCAmelCase						=		kind + 2 if kind in [4, 5] else kind
         # first meaning first pair to compare in 'compare_with'
         _lowerCAmelCase						=		max(_lowerCAmelCase  ,      _lowerCAmelCase       )
         _lowerCAmelCase						=		min(_lowerCAmelCase  ,      _lowerCAmelCase       )
         # If it's full house (three count pair + two count pair), make sure
         # first pair is three count and if not then switch them both.
         if kind == 6 and self._card_values.count(_lowerCAmelCase       ) != 3:
           _lowerCAmelCase	,       _lowerCAmelCase						=		second, first
         _lowerCAmelCase						=		first
         _lowerCAmelCase						=		second
         return kind



       def SCREAMING_SNAKE_CASE_				(     self					:			Optional[int]       )					->   tuple[list[int], set[str]]:
         # Internal representation of hand as a list of card values and
         # a set of card suit
         _lowerCAmelCase						=		{"T": "10", "J": "11", "Q": "12", "K": "13", "A": "14"}
         _lowerCAmelCase						=		self._hand.translate(str.maketrans(_lowerCAmelCase       )       ).split()
         _lowerCAmelCase						=		[int(card[:-1]       ) for card in new_hand]
         _lowerCAmelCase						=		{card[-1] for card in new_hand}
         return sorted(_lowerCAmelCase  ,      reverse=_lowerCAmelCase       ), card_suit



       def __repr__(     self					:			Tuple       )					->   Optional[Any]:
         return F'''{self.__class__}("{self._hand}")'''



       def __str__(     self					:			Optional[int]       )					->   Union[str, Any]:
         return self._hand



       def __eq__(     self					:			Optional[int]  ,      _lowerCAmelCase					:			str       )					->   Tuple:
         if isinstance(_lowerCAmelCase  ,      _lowerCAmelCase       ):
           return self.compare_with(_lowerCAmelCase       ) == "Tie"
         return NotImplemented



       def __lt__(     self					:			List[Any]  ,      _lowerCAmelCase					:			int       )					->   List[str]:
         if isinstance(_lowerCAmelCase  ,      _lowerCAmelCase       ):
           return self.compare_with(_lowerCAmelCase       ) == "Loss"
         return NotImplemented



       def __le__(     self					:			str  ,      _lowerCAmelCase					:			Dict       )					->   str:
         if isinstance(_lowerCAmelCase  ,      _lowerCAmelCase       ):
           return self < other or self == other
         return NotImplemented



       def __gt__(     self					:			Union[str, Any]  ,      _lowerCAmelCase					:			List[Any]       )					->   int:
         if isinstance(_lowerCAmelCase  ,      _lowerCAmelCase       ):
           return not self < other and self != other
         return NotImplemented



       def __ge__(     self					:			Dict  ,      _lowerCAmelCase					:			Dict       )					->   Optional[Any]:
         if isinstance(_lowerCAmelCase  ,      _lowerCAmelCase       ):
           return not self < other
         return NotImplemented






       def __hash__(     self					:			Optional[int]       )					->   List[Any]:
         return object.__hash__(self       )



def 	_a  (					):






  """simple docstring"""




  _lowerCAmelCase						=		0
  _lowerCAmelCase						=		os.path.abspath(os.path.dirname(__SCREAMING_SNAKE_CASE    )    )
  _lowerCAmelCase						=		os.path.join(__SCREAMING_SNAKE_CASE		,				'poker_hands.txt'    )
  with open(__SCREAMING_SNAKE_CASE    ) as file_hand:
    for line in file_hand:
      _lowerCAmelCase						=		line[:14].strip()
      _lowerCAmelCase						=		line[15:].strip()
      _lowerCAmelCase	,       _lowerCAmelCase						=		PokerHand(__SCREAMING_SNAKE_CASE    ), PokerHand(__SCREAMING_SNAKE_CASE    )
      _lowerCAmelCase						=		player.compare_with(__SCREAMING_SNAKE_CASE    )
      if output == "Win":
        answer += 1
  return answer


if __name__ == "__main__":
       solution()
