





from __future__ import annotations

import os

class   __snake_case				:






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

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





    def __init__(   self						:		List[str]			,						snake_case						:		int							):

      """simple docstring"""





      if not isinstance(__SCREAMING_SNAKE_CASE			,						__SCREAMING_SNAKE_CASE							):
        __lowerCAmelCase			=				f'''Hand should be of type \'str\': {hand!r}'''
        raise TypeError(__SCREAMING_SNAKE_CASE							)
      # 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(__SCREAMING_SNAKE_CASE							)
      __lowerCAmelCase			=				hand
      __lowerCAmelCase			=				0
      __lowerCAmelCase			=				0
      __lowerCAmelCase	,						__lowerCAmelCase			=				self._internal_state()
      __lowerCAmelCase			=				self._get_hand_type()
      __lowerCAmelCase			=				self._card_values[0]





    @property
    def 	A		(   self						:		Dict							):

      """simple docstring"""





      return self._hand





    def 	A		(   self						:		Optional[int]			,						snake_case						:		List[str]							):

      """simple docstring"""





      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(__SCREAMING_SNAKE_CASE							)
        else:
          return "Win" if self._second_pair > other._second_pair else "Loss"
      return "Win" if self._first_pair > other._first_pair else "Loss"





    def 	A		(   self						:		Tuple							):

      """simple docstring"""





      __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 	A		(   self						:		Optional[Any]			,						snake_case						:		Optional[int]							):

      """simple docstring"""





      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 	A		(   self						:		Optional[Any]							):

      """simple docstring"""





      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 	A		(   self						:		int							):

      """simple docstring"""





      return len(self._card_suit							) == 1





    def 	A		(   self						:		Any							):

      """simple docstring"""





      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(__SCREAMING_SNAKE_CASE							)
        return True
      return False





    def 	A		(   self						:		Any							):

      """simple docstring"""





      for i in range(4							):
        if self._card_values[i] - self._card_values[i + 1] != 1:
          return False
      return True





    def 	A		(   self						:		List[str]							):

      """simple docstring"""





      __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(__SCREAMING_SNAKE_CASE			,						__SCREAMING_SNAKE_CASE							)
      __lowerCAmelCase			=				min(__SCREAMING_SNAKE_CASE			,						__SCREAMING_SNAKE_CASE							)
      # 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(__SCREAMING_SNAKE_CASE							) != 3:
        __lowerCAmelCase	,						__lowerCAmelCase			=				second, first
      __lowerCAmelCase			=				first
      __lowerCAmelCase			=				second
      return kind





    def 	A		(   self						:		int							):

      """simple docstring"""





      __lowerCAmelCase			=				{'''T''': '''10''', '''J''': '''11''', '''Q''': '''12''', '''K''': '''13''', '''A''': '''14'''}
      __lowerCAmelCase			=				self._hand.translate(str.maketrans(__SCREAMING_SNAKE_CASE							)							).split()
      __lowerCAmelCase			=				[int(card[:-1]							) for card in new_hand]
      __lowerCAmelCase			=				{card[-1] for card in new_hand}
      return sorted(__SCREAMING_SNAKE_CASE			,						reverse=__SCREAMING_SNAKE_CASE							), card_suit





    def __repr__(   self						:		Optional[int]							):

      """simple docstring"""





      return f'''{self.__class__}(\"{self._hand}\")'''





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

      """simple docstring"""





      return self._hand





    def __eq__(   self						:		str			,						snake_case						:		List[Any]							):

      """simple docstring"""





      if isinstance(__SCREAMING_SNAKE_CASE			,						__SCREAMING_SNAKE_CASE							):
        return self.compare_with(__SCREAMING_SNAKE_CASE							) == "Tie"
      return NotImplemented





    def __lt__(   self						:		str			,						snake_case						:		Any							):

      """simple docstring"""





      if isinstance(__SCREAMING_SNAKE_CASE			,						__SCREAMING_SNAKE_CASE							):
        return self.compare_with(__SCREAMING_SNAKE_CASE							) == "Loss"
      return NotImplemented





    def __le__(   self						:		List[str]			,						snake_case						:		Dict							):

      """simple docstring"""





      if isinstance(__SCREAMING_SNAKE_CASE			,						__SCREAMING_SNAKE_CASE							):
        return self < other or self == other
      return NotImplemented





    def __gt__(   self						:		List[str]			,						snake_case						:		Dict							):

      """simple docstring"""





      if isinstance(__SCREAMING_SNAKE_CASE			,						__SCREAMING_SNAKE_CASE							):
        return not self < other and self != other
      return NotImplemented





    def __ge__(   self						:		Union[str, Any]			,						snake_case						:		Optional[int]							):

      """simple docstring"""





      if isinstance(__SCREAMING_SNAKE_CASE			,						__SCREAMING_SNAKE_CASE							):
        return not self < other
      return NotImplemented





    def __hash__(   self						:		Optional[Any]							):

      """simple docstring"""





      return object.__hash__(self							)


def 					__SCREAMING_SNAKE_CASE  (							):



  '''simple docstring'''






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


if __name__ == "__main__":
 solution()







from collections import OrderedDict
from typing import Any, Mapping, Optional

from ... import PreTrainedTokenizer
from ...configuration_utils import PretrainedConfig
from ...file_utils import TensorType, is_torch_available
from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast
from ...onnx.utils import compute_effective_axis_dimension
from ...utils import logging


__lowercase													=			logging.get_logger(__name__)

__lowercase													=			{
    """facebook/blenderbot-3B""": """https://huggingface.co/facebook/blenderbot-3B/resolve/main/config.json""",
    # See all Blenderbot models at https://huggingface.co/models?filter=blenderbot
}

class   __snake_case				(			_a   ):






    '''simple docstring'''
    _lowerCAmelCase     =	"""blenderbot"""
    _lowerCAmelCase     =	["""past_key_values"""]
    _lowerCAmelCase     =	{"""num_attention_heads""": """encoder_attention_heads""", """hidden_size""": """d_model"""}





    def __init__(   self						:		Any			,						snake_case						:		Union[str, Any]=8_008			,						snake_case						:		List[str]=128			,						snake_case						:		Tuple=2			,						snake_case						:		int=10_240			,						snake_case						:		Optional[int]=32			,						snake_case						:		Dict=24			,						snake_case						:		List[Any]=10_240			,						snake_case						:		Optional[int]=32			,						snake_case						:		List[str]=0.0			,						snake_case						:		Optional[int]=0.0			,						snake_case						:		Optional[Any]=True			,						snake_case						:		int=True			,						snake_case						:		List[str]="gelu"			,						snake_case						:		Any=2_560			,						snake_case						:		Optional[Any]=0.1			,						snake_case						:		Union[str, Any]=0.0			,						snake_case						:		List[Any]=0.0			,						snake_case						:		Dict=0.02			,						snake_case						:		int=1			,						snake_case						:		Dict=False			,						snake_case						:		List[str]=0			,						snake_case						:		Optional[Any]=1			,						snake_case						:		List[Any]=2			,						snake_case						:		List[str]=3			,						snake_case						:		List[str]=2			,						**snake_case						:		int			,						):

      """simple docstring"""





      __lowerCAmelCase			=				vocab_size
      __lowerCAmelCase			=				max_position_embeddings
      __lowerCAmelCase			=				d_model
      __lowerCAmelCase			=				encoder_ffn_dim
      __lowerCAmelCase			=				encoder_layers
      __lowerCAmelCase			=				encoder_attention_heads
      __lowerCAmelCase			=				decoder_ffn_dim
      __lowerCAmelCase			=				decoder_layers
      __lowerCAmelCase			=				decoder_attention_heads
      __lowerCAmelCase			=				dropout
      __lowerCAmelCase			=				attention_dropout
      __lowerCAmelCase			=				activation_dropout
      __lowerCAmelCase			=				activation_function
      __lowerCAmelCase			=				init_std
      __lowerCAmelCase			=				encoder_layerdrop
      __lowerCAmelCase			=				decoder_layerdrop
      __lowerCAmelCase			=				use_cache
      __lowerCAmelCase			=				encoder_layers
      __lowerCAmelCase			=				scale_embedding  # scale factor will be sqrt(d_model) if True

      super().__init__(
          pad_token_id=snake_case			,						bos_token_id=snake_case			,						eos_token_id=snake_case			,						is_encoder_decoder=snake_case			,						decoder_start_token_id=snake_case			,						encoder_no_repeat_ngram_size=snake_case			,						forced_eos_token_id=snake_case			,						**snake_case			,						)


class   __snake_case				(			_a   ):






    '''simple docstring'''





    @property
    def 	A		(   self						:		int							):

      """simple docstring"""





      if self.task in ["default", "seq2seq-lm"]:
        __lowerCAmelCase			=				OrderedDict(
            [
                ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
                ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
            ]							)
        if self.use_past:
          __lowerCAmelCase			=				{0: '''batch'''}
          __lowerCAmelCase			=				{0: '''batch''', 1: '''past_decoder_sequence + sequence'''}
        else:
          __lowerCAmelCase			=				{0: '''batch''', 1: '''decoder_sequence'''}
          __lowerCAmelCase			=				{0: '''batch''', 1: '''decoder_sequence'''}
        if self.use_past:
          self.fill_with_past_key_values_(snake_case			,						direction='''inputs'''							)
      elif self.task == "causal-lm":
        __lowerCAmelCase			=				OrderedDict(
            [
                ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
                ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
            ]							)
        if self.use_past:
          __lowerCAmelCase	,						__lowerCAmelCase			=				self.num_layers
          for i in range(snake_case							):
            __lowerCAmelCase			=				{0: '''batch''', 2: '''past_sequence + sequence'''}
            __lowerCAmelCase			=				{0: '''batch''', 2: '''past_sequence + sequence'''}
      else:
        __lowerCAmelCase			=				OrderedDict(
            [
                ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
                ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
                ('''decoder_input_ids''', {0: '''batch''', 1: '''decoder_sequence'''}),
                ('''decoder_attention_mask''', {0: '''batch''', 1: '''decoder_sequence'''}),
            ]							)

      return common_inputs





    @property
    # Copied from transformers.models.bart.configuration_bart.BartOnnxConfig.outputs
    def 	A		(   self						:		Optional[Any]							):

      """simple docstring"""





      if self.task in ["default", "seq2seq-lm"]:
        __lowerCAmelCase			=				super().outputs
      else:
        __lowerCAmelCase			=				super(snake_case			,						self							).outputs
        if self.use_past:
          __lowerCAmelCase	,						__lowerCAmelCase			=				self.num_layers
          for i in range(snake_case							):
            __lowerCAmelCase			=				{0: '''batch''', 2: '''past_sequence + sequence'''}
            __lowerCAmelCase			=				{0: '''batch''', 2: '''past_sequence + sequence'''}
      return common_outputs





    def 	A		(   self						:		int			,						snake_case						:		PreTrainedTokenizer			,						snake_case						:		int = -1			,						snake_case						:		int = -1			,						snake_case						:		bool = False			,						snake_case						:		Optional[TensorType] = None			,						):

      """simple docstring"""





      __lowerCAmelCase			=				self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
          snake_case			,						snake_case			,						snake_case			,						snake_case			,						snake_case							)
      # Generate decoder inputs
      __lowerCAmelCase			=				seq_length if not self.use_past else 1
      __lowerCAmelCase			=				self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
          snake_case			,						snake_case			,						snake_case			,						snake_case			,						snake_case							)
      __lowerCAmelCase			=				{f'''decoder_{name}''': tensor for name, tensor in decoder_inputs.items()}
      __lowerCAmelCase			=				dict(**snake_case			,						**snake_case							)

      if self.use_past:
        if not is_torch_available():
          raise ValueError('''Cannot generate dummy past_keys inputs without PyTorch installed.'''							)
        else:
          import torch
        __lowerCAmelCase	,						__lowerCAmelCase			=				common_inputs['''input_ids'''].shape
        __lowerCAmelCase			=				common_inputs['''decoder_input_ids'''].shape[1]
        __lowerCAmelCase	,						__lowerCAmelCase			=				self.num_attention_heads
        __lowerCAmelCase			=				(
            batch,
            num_encoder_attention_heads,
            encoder_seq_length,
            self._config.hidden_size // num_encoder_attention_heads,
        )
        __lowerCAmelCase			=				decoder_seq_length
        __lowerCAmelCase			=				(
            batch,
            num_decoder_attention_heads,
            decoder_past_length,
            self._config.hidden_size // num_decoder_attention_heads,
        )
        __lowerCAmelCase			=				torch.cat(
            [common_inputs['''decoder_attention_mask'''], torch.ones(snake_case			,						snake_case							)]			,						dim=1							)
        __lowerCAmelCase			=				[]
        __lowerCAmelCase	,						__lowerCAmelCase			=				self.num_layers

        for _ in range(snake_case							):
          common_inputs["past_key_values"].append(
              (
                  torch.zeros(snake_case							),
                  torch.zeros(snake_case							),
                  torch.zeros(snake_case							),
                  torch.zeros(snake_case							),
              )							)
      return common_inputs





    def 	A		(   self						:		str			,						snake_case						:		PreTrainedTokenizer			,						snake_case						:		int = -1			,						snake_case						:		int = -1			,						snake_case						:		bool = False			,						snake_case						:		Optional[TensorType] = None			,						):

      """simple docstring"""





      __lowerCAmelCase			=				self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
          snake_case			,						snake_case			,						snake_case			,						snake_case			,						snake_case							)

      if self.use_past:
        if not is_torch_available():
          raise ValueError('''Cannot generate dummy past_keys inputs without PyTorch installed.'''							)
        else:
          import torch
        __lowerCAmelCase	,						__lowerCAmelCase			=				common_inputs['''input_ids'''].shape
        __lowerCAmelCase			=				seqlen
        __lowerCAmelCase	,						__lowerCAmelCase			=				self.num_layers
        __lowerCAmelCase	,						__lowerCAmelCase			=				self.num_attention_heads
        __lowerCAmelCase			=				(
            batch,
            num_encoder_attention_heads,
            past_key_values_length,
            self._config.hidden_size // num_encoder_attention_heads,
        )
        __lowerCAmelCase			=				common_inputs['''attention_mask'''].dtype
        __lowerCAmelCase			=				torch.cat(
            [common_inputs['''attention_mask'''], torch.ones(snake_case			,						snake_case			,						dtype=snake_case							)]			,						dim=1							)
        __lowerCAmelCase			=				[
            (torch.zeros(snake_case							), torch.zeros(snake_case							)) for _ in range(snake_case							)
        ]
      return common_inputs





    def 	A		(   self						:		Optional[int]			,						snake_case						:		PreTrainedTokenizer			,						snake_case						:		int = -1			,						snake_case						:		int = -1			,						snake_case						:		bool = False			,						snake_case						:		Optional[TensorType] = None			,						):

      """simple docstring"""





      __lowerCAmelCase			=				compute_effective_axis_dimension(
          snake_case			,						fixed_dimension=OnnxConfig.default_fixed_batch			,						num_token_to_add=0							)

      # If dynamic axis (-1) we forward with a fixed dimension of 8 tokens to avoid optimizations made by ONNX
      __lowerCAmelCase			=				tokenizer.num_special_tokens_to_add(snake_case							)
      __lowerCAmelCase			=				compute_effective_axis_dimension(
          snake_case			,						fixed_dimension=OnnxConfig.default_fixed_sequence			,						num_token_to_add=snake_case							)

      # Generate dummy inputs according to compute batch and sequence
      __lowerCAmelCase			=				[''' '''.join([tokenizer.unk_token]							) * seq_length] * batch_size
      __lowerCAmelCase			=				dict(tokenizer(snake_case			,						return_tensors=snake_case							)							)
      return common_inputs





    def 	A		(   self						:		str			,						snake_case						:		PreTrainedTokenizer			,						snake_case						:		int = -1			,						snake_case						:		int = -1			,						snake_case						:		bool = False			,						snake_case						:		Optional[TensorType] = None			,						):

      """simple docstring"""





      if self.task in ["default", "seq2seq-lm"]:
        __lowerCAmelCase			=				self._generate_dummy_inputs_for_default_and_seqaseq_lm(
            snake_case			,						batch_size=snake_case			,						seq_length=snake_case			,						is_pair=snake_case			,						framework=snake_case							)

      elif self.task == "causal-lm":
        __lowerCAmelCase			=				self._generate_dummy_inputs_for_causal_lm(
            snake_case			,						batch_size=snake_case			,						seq_length=snake_case			,						is_pair=snake_case			,						framework=snake_case							)
      else:
        __lowerCAmelCase			=				self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
            snake_case			,						batch_size=snake_case			,						seq_length=snake_case			,						is_pair=snake_case			,						framework=snake_case							)

      return common_inputs





    def 	A		(   self						:		Optional[Any]			,						snake_case						:		int			,						snake_case						:		str			,						snake_case						:		str			,						snake_case						:		List[str]							):

      """simple docstring"""





      if self.task in ["default", "seq2seq-lm"]:
        __lowerCAmelCase			=				super()._flatten_past_key_values_(snake_case			,						snake_case			,						snake_case			,						snake_case							)
      else:
        __lowerCAmelCase			=				super(snake_case			,						self							)._flatten_past_key_values_(
            snake_case			,						snake_case			,						snake_case			,						snake_case							)





    def 	A		(   self						:		List[Any]			,						snake_case						:		Mapping[str, Mapping[int, str]]			,						snake_case						:		str							):

      """simple docstring"""





      if direction not in ["inputs", "outputs"]:
        raise ValueError(f'''direction must either be "inputs" or "outputs", but {direction} was given'''							)

      __lowerCAmelCase			=				'''past_key_values''' if direction == '''inputs''' else '''present'''
      __lowerCAmelCase	,						__lowerCAmelCase			=				self.num_layers

      __lowerCAmelCase			=				'''past_encoder_sequence'''
      __lowerCAmelCase			=				'''past_decoder_sequence''' if direction == '''inputs''' else '''past_decoder_sequence + sequence'''

      for i in range(snake_case							):
        __lowerCAmelCase			=				{0: '''batch''', 2: decoder_sequence}
        __lowerCAmelCase			=				{0: '''batch''', 2: decoder_sequence}
        __lowerCAmelCase			=				{0: '''batch''', 2: encoder_sequence}
        __lowerCAmelCase			=				{0: '''batch''', 2: encoder_sequence}
