code: 
  
  
  
  
  
  
  from __future__ import annotations
  
  import os
  
  
  
  
  
  class     __a						:
   _lowerCAmelCase : Optional[int] 				=				(
       '''High card''',
       '''One pair''',
       '''Two pairs''',
       '''Three of a kind''',
       '''Straight''',
       '''Flush''',
       '''Full house''',
       '''Four of a kind''',
       '''Straight flush''',
       '''Royal flush''',
   )
  
   _lowerCAmelCase : Optional[Any] 				=				(
       '''''',  # placeholder as tuples are zero-indexed
       '''One''',
       '''Two''',
       '''Three''',
       '''Four''',
       '''Five''',
       '''Six''',
       '''Seven''',
       '''Eight''',
       '''Nine''',
       '''Ten''',
       '''Jack''',
       '''Queen''',
       '''King''',
       '''Ace''',
   )
  
  
  
  
  
  
  
   def __init__(	self      :     Dict							,     SCREAMING_SNAKE_CASE      :     str		):
  
  
        '''simple docstring'''
  
  
  
  
  
  
        if not isinstance(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE		):
             UpperCamelCase__    :     Tuple        =						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:
             UpperCamelCase__    :     List[str]        =						F'Hand should contain only 5 cards: {hand!r}'
             raise ValueError(SCREAMING_SNAKE_CASE		)
        UpperCamelCase__    :     Optional[Any]        =						hand
        UpperCamelCase__    :     Optional[Any]        =						0
        UpperCamelCase__    :     Tuple        =						0
        UpperCamelCase__       ,  UpperCamelCase__    :     str        =						self._internal_state()
        UpperCamelCase__    :     List[Any]        =						self._get_hand_type()
        UpperCamelCase__    :     List[str]        =						self._card_values[0]
  
  
  
  
  
  
  
   @property
   def       __lowercase      (	self      :     Optional[int]		):
  
  
        '''simple docstring'''
  
  
  
  
  
  
        return self._hand
  
  
  
  
  
  
  
   def       __lowercase      (	self      :     str							,     SCREAMING_SNAKE_CASE      :     PokerHand		):
  
  
        '''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       __lowercase      (	self      :     Optional[int]		):
  
  
        '''simple docstring'''
  
  
  
  
  
  
        UpperCamelCase__    :     List[Any]        =						PokerHand._HAND_NAME[self._hand_type - 14]
        UpperCamelCase__    :     List[str]        =						PokerHand._CARD_NAME[self._high_card]
        UpperCamelCase__    :     Optional[Any]        =						PokerHand._CARD_NAME[self._first_pair]
        UpperCamelCase__    :     Optional[Any]        =						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]:
             UpperCamelCase__    :     Optional[int]        =						"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       __lowercase      (	self      :     Dict							,     SCREAMING_SNAKE_CASE      :     PokerHand		):
  
  
        '''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       __lowercase      (	self      :     List[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       __lowercase      (	self      :     Dict		):
  
  
        '''simple docstring'''
  
  
  
  
  
  
        return len(self._card_suit		) == 1
  
  
  
  
  
  
  
   def       __lowercase      (	self      :     Optional[int]		):
  
  
        '''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
                  UpperCamelCase__    :     int        =						self._card_values.pop(0		)
                  self._card_values.append(SCREAMING_SNAKE_CASE		)
             return True
        return False
  
  
  
  
  
  
  
   def       __lowercase      (	self      :     Optional[int]		):
  
  
        '''simple docstring'''
  
  
  
  
  
  
        for i in range(4		):
             if self._card_values[i] - self._card_values[i + 1] != 1:
                  return False
        return True
  
  
  
  
  
  
  
   def       __lowercase      (	self      :     Optional[int]		):
  
  
        '''simple docstring'''
  
  
  
  
  
  
        UpperCamelCase__    :     int        =						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:
                       UpperCamelCase__    :     Union[str, Any]        =						self._card_values[i]
                       kind += 1
                  elif vala == self._card_values[i]:
                       kind += 2
                  elif not vala:
                       UpperCamelCase__    :     Dict        =						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)
        UpperCamelCase__    :     str        =						kind + 2 if kind in [4, 5] else kind
        # first meaning first pair to compare in 'compare_with'
        UpperCamelCase__    :     List[Any]        =						max(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE		)
        UpperCamelCase__    :     Dict        =						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:
             UpperCamelCase__       ,  UpperCamelCase__    :     List[Any]        =						second, first
        UpperCamelCase__    :     Any        =						first
        UpperCamelCase__    :     Optional[int]        =						second
        return kind
  
  
  
  
  
  
  
   def       __lowercase      (	self      :     Dict		):
  
  
        '''simple docstring'''
  
  
  
  
  
  
        UpperCamelCase__    :     dict        =						{"T": "10", "J": "11", "Q": "12", "K": "13", "A": "14"}
        UpperCamelCase__    :     str        =						self._hand.translate(str.maketrans(SCREAMING_SNAKE_CASE		)		).split()
        UpperCamelCase__    :     Optional[int]        =						[int(card[:-1]		) for card in new_hand]
        UpperCamelCase__    :     str        =						{card[-1] for card in new_hand}
        return sorted(SCREAMING_SNAKE_CASE							,     reverse=SCREAMING_SNAKE_CASE		), card_suit
  
  
  
  
  
  
  
   def __repr__(	self      :     Any		):
  
  
        '''simple docstring'''
  
  
  
  
  
  
        return F'{self.__class__}("{self._hand}")'
  
  
  
  
  
  
  
   def __str__(	self      :     Optional[int]		):
  
  
        '''simple docstring'''
  
  
  
  
  
  
        return self._hand
  
  
  
  
  
  
  
   def __eq__(	self      :     List[str]							,     SCREAMING_SNAKE_CASE      :     Union[str, Any]		):
  
  
        '''simple docstring'''
  
  
  
  
  
  
        if isinstance(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE		):
             return self.compare_with(SCREAMING_SNAKE_CASE		) == "Tie"
        return NotImplemented
  
  
  
  
  
  
  
   def __lt__(	self      :     Optional[Any]							,     SCREAMING_SNAKE_CASE      :     Optional[Any]		):
  
  
        '''simple docstring'''
  
  
  
  
  
  
        if isinstance(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE		):
             return self.compare_with(SCREAMING_SNAKE_CASE		) == "Loss"
        return NotImplemented
  
  
  
  
  
  
  
   def __le__(	self      :     Optional[Any]							,     SCREAMING_SNAKE_CASE      :     Optional[int]		):
  
  
        '''simple docstring'''
  
  
  
  
  
  
        if isinstance(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE		):
             return self < other or self == other
        return NotImplemented
  
  
  
  
  
  
  
   def __gt__(	self      :     str							,     SCREAMING_SNAKE_CASE      :     Optional[Any]		):
  
  
        '''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]							,     SCREAMING_SNAKE_CASE      :     Union[str, Any]		):
  
  
        '''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							(      )				->			int:
       # Solution for problem number 54 from Project Euler
       # Input from poker_hands.txt file
       UpperCamelCase__    :     List[str]        =						0
       UpperCamelCase__    :     List[str]        =						os.path.abspath(os.path.dirname(__lowerCAmelCase    )    )
       UpperCamelCase__    :     Any        =						os.path.join(__lowerCAmelCase      ,					"poker_hands.txt"    )
       with open(__lowerCAmelCase    ) as file_hand:
            for line in file_hand:
                 UpperCamelCase__    :     Union[str, Any]        =						line[:14].strip()
                 UpperCamelCase__    :     Optional[Any]        =						line[15:].strip()
                 UpperCamelCase__       ,  UpperCamelCase__    :     List[Any]        =						PokerHand(__lowerCAmelCase    ), PokerHand(__lowerCAmelCase    )
                 UpperCamelCase__    :     Tuple        =						player.compare_with(__lowerCAmelCase    )
                 if output == "Win":
                      answer += 1
       return answer
  
  
  if __name__ == "__main__":
   solution()
style_context: 
  
  
  
  
  
  
  import unittest
  
  from transformers import (
      MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING,
      TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING,
      PreTrainedTokenizer,
      is_vision_available,
  )
  from transformers.pipelines import ImageClassificationPipeline, pipeline
  from transformers.testing_utils import (
      is_pipeline_test,
      nested_simplify,
      require_tf,
      require_torch,
      require_torch_or_tf,
      require_vision,
      slow,
  )
  
  from .test_pipelines_common import ANY
  
  
  if is_vision_available():
   from PIL import Image
  else:
  
  
  
  
  
   class     __a						:
  
  
  
  
  
  
  
    @staticmethod
    def       __lowercase      (	*SCREAMING_SNAKE_CASE      :     Optional[Any]							,     **SCREAMING_SNAKE_CASE      :     Union[str, Any]		):
  
  
         '''simple docstring'''
  
  
  
  
  
  
         pass
  
  
  
  
  
  @is_pipeline_test
  @require_torch_or_tf
  @require_vision
  class     __a						(					unittest.TestCase ):
   _lowerCAmelCase : Tuple 				=				MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
   _lowerCAmelCase : str 				=				TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
  
  
  
  
  
  
  
   def       __lowercase      (	self      :     Union[str, Any]							,     SCREAMING_SNAKE_CASE      :     str							,     SCREAMING_SNAKE_CASE      :     Union[str, Any]							,     SCREAMING_SNAKE_CASE      :     Optional[Any]		):
  
  
        '''simple docstring'''
  
  
  
  
  
  
        UpperCamelCase__    :     Dict        =						ImageClassificationPipeline(model=SCREAMING_SNAKE_CASE							,     image_processor=SCREAMING_SNAKE_CASE							,     top_k=2		)
        UpperCamelCase__    :     Union[str, Any]        =						[
            Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"		),
            "http://images.cocodataset.org/val2017/000000039769.jpg",
        ]
        return image_classifier, examples
  
  
  
  
  
  
  
   def       __lowercase      (	self      :     Tuple							,     SCREAMING_SNAKE_CASE      :     Tuple							,     SCREAMING_SNAKE_CASE      :     Tuple		):
  
  
        '''simple docstring'''
  
  
  
  
  
  
        UpperCamelCase__    :     Optional[Any]        =						image_classifier("./tests/fixtures/tests_samples/COCO/000000039769.png"		)
  
        self.assertEqual(
            SCREAMING_SNAKE_CASE							,     [
                {"score": ANY(SCREAMING_SNAKE_CASE		), "label": ANY(SCREAMING_SNAKE_CASE		)},
                {"score": ANY(SCREAMING_SNAKE_CASE		), "label": ANY(SCREAMING_SNAKE_CASE		)},
            ]							,     )
  
        import datasets
  
        UpperCamelCase__    :     int        =						datasets.load_dataset("hf-internal-testing/fixtures_image_utils"							,     "image"							,     split="test"		)
  
        # Accepts URL + PIL.Image + lists
        UpperCamelCase__    :     Tuple        =						image_classifier(
            [
                Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"		),
                "http://images.cocodataset.org/val2017/000000039769.jpg",
                # RGBA
                dataset[0]["file"],
                # LA
                dataset[1]["file"],
                # L
                dataset[2]["file"],
            ]		)
        self.assertEqual(
            SCREAMING_SNAKE_CASE							,     [
                [
                    {"score": ANY(SCREAMING_SNAKE_CASE		), "label": ANY(SCREAMING_SNAKE_CASE		)},
                    {"score": ANY(SCREAMING_SNAKE_CASE		), "label": ANY(SCREAMING_SNAKE_CASE		)},
                ],
                [
                    {"score": ANY(SCREAMING_SNAKE_CASE		), "label": ANY(SCREAMING_SNAKE_CASE		)},
                    {"score": ANY(SCREAMING_SNAKE_CASE		), "label": ANY(SCREAMING_SNAKE_CASE		)},
                ],
                [
                    {"score": ANY(SCREAMING_SNAKE_CASE		), "label": ANY(SCREAMING_SNAKE_CASE		)},
                    {"score": ANY(SCREAMING_SNAKE_CASE		), "label": ANY(SCREAMING_SNAKE_CASE		)},
                ],
                [
                    {"score": ANY(SCREAMING_SNAKE_CASE		), "label": ANY(SCREAMING_SNAKE_CASE		)},
                    {"score": ANY(SCREAMING_SNAKE_CASE		), "label": ANY(SCREAMING_SNAKE_CASE		)},
                ],
                [
                    {"score": ANY(SCREAMING_SNAKE_CASE		), "label": ANY(SCREAMING_SNAKE_CASE		)},
                    {"score": ANY(SCREAMING_SNAKE_CASE		), "label": ANY(SCREAMING_SNAKE_CASE		)},
                ],
            ]							,     )
  
  
  
  
  
  
  
   @require_torch
   def       __lowercase      (	self      :     List[str]		):
  
  
        '''simple docstring'''
  
  
  
  
  
  
        UpperCamelCase__    :     List[Any]        =						"hf-internal-testing/tiny-random-vit"
        UpperCamelCase__    :     List[str]        =						pipeline("image-classification"							,     model=SCREAMING_SNAKE_CASE		)
  
        UpperCamelCase__    :     List[str]        =						image_classifier("http://images.cocodataset.org/val2017/000000039769.jpg"		)
        self.assertEqual(
            nested_simplify(SCREAMING_SNAKE_CASE							,     decimals=4		)							,     [{"label": "LABEL_1", "score": 0.5_7_4}, {"label": "LABEL_0", "score": 0.4_2_6}]							,     )
  
        UpperCamelCase__    :     Optional[Any]        =						image_classifier(
            [
                "http://images.cocodataset.org/val2017/000000039769.jpg",
                "http://images.cocodataset.org/val2017/000000039769.jpg",
            ]							,     top_k=2							,     )
        self.assertEqual(
            nested_simplify(SCREAMING_SNAKE_CASE							,     decimals=4		)							,     [
                [{"label": "LABEL_1", "score": 0.5_7_4}, {"label": "LABEL_0", "score": 0.4_2_6}],
                [{"label": "LABEL_1", "score": 0.5_7_4}, {"label": "LABEL_0", "score": 0.4_2_6}],
            ]							,     )
  
  
  
  
  
  
  
   @require_tf
   def       __lowercase      (	self      :     int		):
  
  
        '''simple docstring'''
  
  
  
  
  
  
        UpperCamelCase__    :     str        =						"hf-internal-testing/tiny-random-vit"
        UpperCamelCase__    :     int        =						pipeline("image-classification"							,     model=SCREAMING_SNAKE_CASE							,     framework="tf"		)
  
        UpperCamelCase__    :     List[Any]        =						image_classifier("http://images.cocodataset.org/val2017/000000039769.jpg"		)
        self.assertEqual(
            nested_simplify(SCREAMING_SNAKE_CASE							,     decimals=4		)							,     [{"label": "LABEL_1", "score": 0.5_7_4}, {"label": "LABEL_0", "score": 0.4_2_6}]							,     )
  
        UpperCamelCase__    :     int        =						image_classifier(
            [
                "http://images.cocodataset.org/val2017/000000039769.jpg",
                "http://images.cocodataset.org/val2017/000000039769.jpg",
            ]							,     top_k=2							,     )
        self.assertEqual(
            nested_simplify(SCREAMING_SNAKE_CASE							,     decimals=4		)							,     [
                [{"label": "LABEL_1", "score": 0.5_7_4}, {"label": "LABEL_0", "score": 0.4_2_6}],
                [{"label": "LABEL_1", "score": 0.5_7_4}, {"label": "LABEL_0", "score": 0.4_2_6}],
            ]							,     )
  
  
  
  
  
  
  
   def       __lowercase      (	self      :     Optional[int]		):
  
  
        '''simple docstring'''
  
  
  
  
  
  
        UpperCamelCase__    :     Any        =						PreTrainedTokenizer()
  
        # Assert that the pipeline can be initialized with a feature extractor that is not in any mapping
        UpperCamelCase__    :     str        =						pipeline(
            "image-classification"							,     model="hf-internal-testing/tiny-random-vit"							,     tokenizer=SCREAMING_SNAKE_CASE		)
  
        self.assertIs(image_classifier.tokenizer							,     SCREAMING_SNAKE_CASE		)
  
  
  
  
  
  
  
   @slow
   @require_torch
   def       __lowercase      (	self      :     int		):
  
  
        '''simple docstring'''
  
  
  
  
  
  
        UpperCamelCase__    :     Optional[Any]        =						pipeline("image-classification"							,     model="deepmind/vision-perceiver-conv"		)
        UpperCamelCase__    :     Any        =						image_classifier("http://images.cocodataset.org/val2017/000000039769.jpg"		)
        self.assertEqual(
            nested_simplify(SCREAMING_SNAKE_CASE							,     decimals=4		)							,     [
                {"score": 0.4_3_8_5, "label": "tabby, tabby cat"},
                {"score": 0.3_2_1, "label": "tiger cat"},
                {"score": 0.0_5_0_2, "label": "Egyptian cat"},
                {"score": 0.0_1_3_7, "label": "crib, cot"},
                {"score": 0.0_0_7, "label": "radiator"},
            ]							,     )
  
        UpperCamelCase__    :     Optional[Any]        =						pipeline("image-classification"							,     model="deepmind/vision-perceiver-fourier"		)
        UpperCamelCase__    :     List[str]        =						image_classifier("http://images.cocodataset.org/val2017/000000039769.jpg"		)
        self.assertEqual(
            nested_simplify(SCREAMING_SNAKE_CASE							,     decimals=4		)							,     [
                {"score": 0.5_6_5_8, "label": "tabby, tabby cat"},
                {"score": 0.1_3_0_9, "label": "tiger cat"},
                {"score": 0.0_7_2_2, "label": "Egyptian cat"},
                {"score": 0.0_7_0_7, "label": "remote control, remote"},
                {"score": 0.0_0_8_2, "label": "computer keyboard, keypad"},
            ]							,     )
  
        UpperCamelCase__    :     List[str]        =						pipeline("image-classification"							,     model="deepmind/vision-perceiver-learned"		)
        UpperCamelCase__    :     Optional[int]        =						image_classifier("http://images.cocodataset.org/val2017/000000039769.jpg"		)
        self.assertEqual(
            nested_simplify(SCREAMING_SNAKE_CASE							,     decimals=4		)							,     [
                {"score": 0.3_0_2_2, "label": "tabby, tabby cat"},
                {"score": 0.2_3_6_2, "label": "Egyptian cat"},
                {"score": 0.1_8_5_6, "label": "tiger cat"},
                {"score": 0.0_3_2_4, "label": "remote control, remote"},
                {"score": 0.0_0_9_6, "label": "quilt, comforter, comfort, puff"},
            ]							,     )