





from typing import Optional, Union

import torch
from torch import nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss

from ...activations import ACTaFN
from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention
from ...modeling_utils import PreTrainedModel
from ...utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
from .configuration_mobilenet_va import MobileNetVaConfig


_SCREAMING_SNAKE_CASE							=						logging.get_logger(__name__)


# General docstring
_SCREAMING_SNAKE_CASE							=						"""MobileNetV1Config"""

# Base docstring
_SCREAMING_SNAKE_CASE							=						"""google/mobilenet_v1_1.0_224"""
_SCREAMING_SNAKE_CASE							=						[1, 10_24, 7, 7]

# Image classification docstring
_SCREAMING_SNAKE_CASE							=						"""google/mobilenet_v1_1.0_224"""
_SCREAMING_SNAKE_CASE							=						"""tabby, tabby cat"""


_SCREAMING_SNAKE_CASE							=						[
    """google/mobilenet_v1_1.0_224""",
    """google/mobilenet_v1_0.75_192""",
    # See all MobileNetV1 models at https://huggingface.co/models?filter=mobilenet_v1
]


def 							SCREAMING_SNAKE_CASE__  (			__a      ,       __a      ,       __a=None      ):
	snake_case_						:	Union[str, Any]      =		{}

	if isinstance(_UpperCamelCase      ,       _UpperCamelCase      ):
		snake_case_						:	Optional[Any]      =		model.mobilenet_va
	else:
		snake_case_						:	Optional[Any]      =		model

	snake_case_						:	Optional[int]      =		'''MobilenetV1/Conv2d_0/'''
	snake_case_						:	List[str]      =		backbone.conv_stem.convolution.weight
	snake_case_						:	Any      =		backbone.conv_stem.normalization.bias
	snake_case_						:	List[str]      =		backbone.conv_stem.normalization.weight
	snake_case_						:	Dict      =		backbone.conv_stem.normalization.running_mean
	snake_case_						:	Optional[int]      =		backbone.conv_stem.normalization.running_var

	for i in range(13      ):
		snake_case_						:	str      =		i + 1
		snake_case_						:	List[Any]      =		i * 2

		snake_case_						:	Tuple      =		backbone.layer[pt_index]
		snake_case_						:	List[str]      =		f"""MobilenetV1/Conv2d_{tf_index}_depthwise/"""
		snake_case_						:	int      =		pointer.convolution.weight
		snake_case_						:	Tuple      =		pointer.normalization.bias
		snake_case_						:	Optional[int]      =		pointer.normalization.weight
		snake_case_						:	int      =		pointer.normalization.running_mean
		snake_case_						:	List[Any]      =		pointer.normalization.running_var

		snake_case_						:	List[Any]      =		backbone.layer[pt_index + 1]
		snake_case_						:	Dict      =		f"""MobilenetV1/Conv2d_{tf_index}_pointwise/"""
		snake_case_						:	List[Any]      =		pointer.convolution.weight
		snake_case_						:	Optional[int]      =		pointer.normalization.bias
		snake_case_						:	List[str]      =		pointer.normalization.weight
		snake_case_						:	Union[str, Any]      =		pointer.normalization.running_mean
		snake_case_						:	Optional[Any]      =		pointer.normalization.running_var

	if isinstance(_UpperCamelCase      ,       _UpperCamelCase      ):
		snake_case_						:	Optional[int]      =		'''MobilenetV1/Logits/Conv2d_1c_1x1/'''
		snake_case_						:	int      =		model.classifier.weight
		snake_case_						:	Tuple      =		model.classifier.bias

	return tf_to_pt_map


def 							SCREAMING_SNAKE_CASE__  (			__a      ,       __a      ,       __a      ):


	try:
		import numpy as np
		import tensorflow as tf
	except ImportError:
		logger.error(
		    'Loading a TensorFlow models in PyTorch, requires TensorFlow to be installed. Please see '
		    'https://www.tensorflow.org/install/ for installation instructions.'      )
		raise

	# Load weights from TF model
	snake_case_						:	List[str]      =		tf.train.list_variables(_UpperCamelCase      )
	snake_case_						:	Dict      =		{}
	for name, shape in init_vars:
		logger.info(f"""Loading TF weight {name} with shape {shape}"""      )
		snake_case_						:	Dict      =		tf.train.load_variable(_UpperCamelCase      ,       _UpperCamelCase      )
		snake_case_						:	Optional[int]      =		array

	# Build TF to PyTorch weights loading map
	snake_case_						:	str      =		_build_tf_to_pytorch_map(_UpperCamelCase      ,       _UpperCamelCase      ,       _UpperCamelCase      )

	for name, pointer in tf_to_pt_map.items():
		logger.info(f"""Importing {name}"""      )
		if name not in tf_weights:
			logger.info(f"""{name} not in tf pre-trained weights, skipping"""      )
			continue

		snake_case_						:	str      =		tf_weights[name]

		if "depthwise_weights" in name:
			logger.info('Transposing depthwise'      )
			snake_case_						:	List[str]      =		np.transpose(_UpperCamelCase      ,       (2, 3, 0, 1)      )
		elif "weights" in name:
			logger.info('Transposing'      )
			if len(pointer.shape      ) == 2:  # copying into linear layer
				snake_case_						:	int      =		array.squeeze().transpose()
			else:
				snake_case_						:	Union[str, Any]      =		np.transpose(_UpperCamelCase      ,       (3, 2, 0, 1)      )

		if pointer.shape != array.shape:
			raise ValueError(f"""Pointer shape {pointer.shape} and array shape {array.shape} mismatched"""      )

		logger.info(f"""Initialize PyTorch weight {name} {array.shape}"""      )
		snake_case_						:	Any      =		torch.from_numpy(_UpperCamelCase      )

		tf_weights.pop(_UpperCamelCase      ,       _UpperCamelCase      )
		tf_weights.pop(name + '/RMSProp'      ,       _UpperCamelCase      )
		tf_weights.pop(name + '/RMSProp_1'      ,       _UpperCamelCase      )
		tf_weights.pop(name + '/ExponentialMovingAverage'      ,       _UpperCamelCase      )

	logger.info(f"""Weights not copied to PyTorch model: {', '.join(tf_weights.keys()      )}"""      )
	return model


def 							SCREAMING_SNAKE_CASE__  (			__a      ,       __a      ):
	snake_case_						:	Any      =		features.shape[-2:]
	snake_case_						:	str      =		conv_layer.stride
	snake_case_						:	List[Any]      =		conv_layer.kernel_size

	if in_height % stride_height == 0:
		snake_case_						:	Tuple      =		max(kernel_height - stride_height      ,       0      )
	else:
		snake_case_						:	Union[str, Any]      =		max(kernel_height - (in_height % stride_height)      ,       0      )

	if in_width % stride_width == 0:
		snake_case_						:	Optional[int]      =		max(kernel_width - stride_width      ,       0      )
	else:
		snake_case_						:	Dict      =		max(kernel_width - (in_width % stride_width)      ,       0      )

	snake_case_						:	Union[str, Any]      =		pad_along_width // 2
	snake_case_						:	Optional[Any]      =		pad_along_width - pad_left
	snake_case_						:	Optional[Any]      =		pad_along_height // 2
	snake_case_						:	Union[str, Any]      =		pad_along_height - pad_top

	snake_case_						:	Tuple      =		(pad_left, pad_right, pad_top, pad_bottom)
	return nn.functional.pad(_UpperCamelCase      ,       _UpperCamelCase      ,       'constant'      ,       0.0      )
class SCREAMING_SNAKE_CASE_  (    nn.Module    ):






						def __init__(					self					:					Any						,      _A					:					Dict						,      _A					:					List[Any]						,      _A					:					List[str]						,      _A					:					List[Any]						,      _A					:					Optional[int] = 1						,      _A					:					List[Any] = 1						,      _A					:					Tuple = False						,      _A					:					Optional[int] = True						,      _A					:					Optional[Any] = True						,      )							->			None:







							"""simple docstring"""


							super().__init__()
							snake_case_						:	Optional[Any]      =		config

							if in_channels % groups != 0:
								raise ValueError(F"""Input channels ({in_channels}) are not divisible by {groups} groups."""		)
							if out_channels % groups != 0:
								raise ValueError(F"""Output channels ({out_channels}) are not divisible by {groups} groups."""		)

							snake_case_						:	List[str]      =		0 if config.tf_padding else int((kernel_size - 1) / 2		)

							snake_case_						:	List[str]      =		nn.Convad(
							    in_channels=_A						,      out_channels=_A						,      kernel_size=_A						,      stride=_A						,      padding=_A						,      groups=_A						,      bias=_A						,      padding_mode='zeros'						,      )

							if use_normalization:
								snake_case_						:	Tuple      =		nn.BatchNormad(
								    num_features=_A						,      eps=config.layer_norm_eps						,      momentum=0.9_9_9_7						,      affine=_A						,      track_running_stats=_A						,      )
							else:
								snake_case_						:	str      =		None

							if use_activation:
								if isinstance(_A						,      _A		):
									snake_case_						:	Optional[Any]      =		ACTaFN[use_activation]
								elif isinstance(config.hidden_act						,      _A		):
									snake_case_						:	Any      =		ACTaFN[config.hidden_act]
								else:
									snake_case_						:	List[str]      =		config.hidden_act
							else:
								snake_case_						:	Any      =		None






						def UpperCAmelCase_ (					self					:					Dict						,      _A					:					Any		)							->			torch.Tensor:







							"""simple docstring"""


							if self.config.tf_padding:
								snake_case_						:	Union[str, Any]      =		apply_tf_padding(_A						,      self.convolution		)
							snake_case_						:	Union[str, Any]      =		self.convolution(_A		)
							if self.normalization is not None:
								snake_case_						:	int      =		self.normalization(_A		)
							if self.activation is not None:
								snake_case_						:	List[Any]      =		self.activation(_A		)
							return features
class SCREAMING_SNAKE_CASE_  (    _a    ):
						__magic_name__:	Tuple       					=				MobileNetVaConfig
						__magic_name__:	Optional[int]       					=				load_tf_weights_in_mobilenet_va
						__magic_name__:	int       					=				'''mobilenet_v1'''
						__magic_name__:	str       					=				'''pixel_values'''
						__magic_name__:	List[str]       					=				False






						def UpperCAmelCase_ (					self					:					List[str]						,      _A					:					Tuple		)							->			None:







							"""simple docstring"""


							if isinstance(_A						,      (nn.Linear, nn.Convad)		):
								module.weight.data.normal_(mean=0.0						,      std=self.config.initializer_range		)
								if module.bias is not None:
									module.bias.data.zero_()
							elif isinstance(_A						,      nn.BatchNormad		):
								module.bias.data.zero_()
								module.weight.data.fill_(1.0		)
_SCREAMING_SNAKE_CASE							=						R"""
    This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass. Use it
    as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
    behavior.

    Parameters:
        config ([`MobileNetV1Config`]): Model configuration class with all the parameters of the model.
            Initializing with a config file does not load the weights associated with the model, only the
            configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
"""

_SCREAMING_SNAKE_CASE							=						R"""
    Args:
        pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):
            Pixel values. Pixel values can be obtained using [`AutoImageProcessor`]. See
            [`MobileNetV1ImageProcessor.__call__`] for details.
        output_hidden_states (`bool`, *optional*):
            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
            more detail.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
"""
@add_start_docstrings(
    "The bare MobileNetV1 model outputting raw hidden-states without any specific head on top."				, _a				, )
class SCREAMING_SNAKE_CASE_  (    _a    ):






						def __init__(					self					:					Tuple						,      _A					:					Dict						,      _A					:					Dict = True		)							->			List[Any]:







							"""simple docstring"""


							super().__init__(_A		)
							snake_case_						:	Union[str, Any]      =		config

							snake_case_						:	str      =		32
							snake_case_						:	Optional[int]      =		max(int(depth * config.depth_multiplier		)						,      config.min_depth		)

							snake_case_						:	List[str]      =		MobileNetVaConvLayer(
							    _A						,      in_channels=config.num_channels						,      out_channels=_A						,      kernel_size=3						,      stride=2						,      )

							snake_case_						:	Any      =		[1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1]

							snake_case_						:	Union[str, Any]      =		nn.ModuleList()
							for i in range(13		):
								snake_case_						:	List[str]      =		out_channels

								if strides[i] == 2 or i == 0:
									depth *= 2
									snake_case_						:	Dict      =		max(int(depth * config.depth_multiplier		)						,      config.min_depth		)

								self.layer.append(
								    MobileNetVaConvLayer(
								        _A						,      in_channels=_A						,      out_channels=_A						,      kernel_size=3						,      stride=strides[i]						,      groups=_A						,      )		)

								self.layer.append(
								    MobileNetVaConvLayer(
								        _A						,      in_channels=_A						,      out_channels=_A						,      kernel_size=1						,      )		)

							snake_case_						:	List[str]      =		nn.AdaptiveAvgPoolad((1, 1)		) if add_pooling_layer else None

							# Initialize weights and apply final processing
							self.post_init()






						def UpperCAmelCase_ (					self					:					Tuple						,      _A					:					Tuple		)							->			Dict:







							"""simple docstring"""


							raise NotImplementedError






						@add_start_docstrings_to_model_forward(_A		)
						@add_code_sample_docstrings(
						    checkpoint=_CHECKPOINT_FOR_DOC						,      output_type=_A						,      config_class=_CONFIG_FOR_DOC						,      modality='vision'						,      expected_output=_EXPECTED_OUTPUT_SHAPE						,      )
						def UpperCAmelCase_ (					self					:					Tuple						,      _A					:					Optional[int] = None						,      _A					:					Any = None						,      _A					:					Dict = None						,      )							->			Union[tuple, BaseModelOutputWithPoolingAndNoAttention]:







							"""simple docstring"""


							snake_case_						:	Tuple      =		(
							    output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
							)
							snake_case_						:	Dict      =		return_dict if return_dict is not None else self.config.use_return_dict

							if pixel_values is None:
								raise ValueError('You have to specify pixel_values'		)

							snake_case_						:	Union[str, Any]      =		self.conv_stem(_A		)

							snake_case_						:	Union[str, Any]      =		() if output_hidden_states else None

							for i, layer_module in enumerate(self.layer		):
								snake_case_						:	List[str]      =		layer_module(_A		)

								if output_hidden_states:
									snake_case_						:	Union[str, Any]      =		all_hidden_states + (hidden_states,)

							snake_case_						:	Any      =		hidden_states

							if self.pooler is not None:
								snake_case_						:	Optional[int]      =		torch.flatten(self.pooler(_A		)						,      start_dim=1		)
							else:
								snake_case_						:	Tuple      =		None

							if not return_dict:
								return tuple(v for v in [last_hidden_state, pooled_output, all_hidden_states] if v is not None		)

							return BaseModelOutputWithPoolingAndNoAttention(
							    last_hidden_state=_A						,      pooler_output=_A						,      hidden_states=_A						,      )
@add_start_docstrings(
    "\n    MobileNetV1 model with an image classification head on top (a linear layer on top of the pooled features), e.g. for\n    ImageNet.\n    "				, _a				, )
class SCREAMING_SNAKE_CASE_  (    _a    ):






						def __init__(					self					:					Any						,      _A					:					Optional[int]		)							->			None:







							"""simple docstring"""


							super().__init__(_A		)

							snake_case_						:	Dict      =		config.num_labels
							snake_case_						:	List[str]      =		MobileNetVaModel(_A		)

							snake_case_						:	Optional[int]      =		self.mobilenet_va.layer[-1].convolution.out_channels

							# Classifier head
							snake_case_						:	Union[str, Any]      =		nn.Dropout(config.classifier_dropout_prob						,      inplace=_A		)
							snake_case_						:	Any      =		nn.Linear(_A						,      config.num_labels		) if config.num_labels > 0 else nn.Identity()

							# Initialize weights and apply final processing
							self.post_init()






						@add_start_docstrings_to_model_forward(_A		)
						@add_code_sample_docstrings(
						    checkpoint=_IMAGE_CLASS_CHECKPOINT						,      output_type=_A						,      config_class=_CONFIG_FOR_DOC						,      expected_output=_IMAGE_CLASS_EXPECTED_OUTPUT						,      )
						def UpperCAmelCase_ (					self					:					Optional[int]						,      _A					:					Optional[Any] = None						,      _A					:					List[Any] = None						,      _A					:					Optional[Any] = None						,      _A					:					List[str] = None						,      )							->			Union[tuple, ImageClassifierOutputWithNoAttention]:







							"""simple docstring"""


							snake_case_						:	List[Any]      =		return_dict if return_dict is not None else self.config.use_return_dict

							snake_case_						:	Any      =		self.mobilenet_va(_A						,      output_hidden_states=_A						,      return_dict=_A		)

							snake_case_						:	Optional[Any]      =		outputs.pooler_output if return_dict else outputs[1]

							snake_case_						:	List[Any]      =		self.classifier(self.dropout(_A		)		)

							snake_case_						:	Optional[Any]      =		None
							if labels is not None:
								if self.config.problem_type is None:
									if self.num_labels == 1:
										snake_case_						:	List[str]      =		'''regression'''
									elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
										snake_case_						:	List[str]      =		'''single_label_classification'''
									else:
										snake_case_						:	Optional[Any]      =		'''multi_label_classification'''

								if self.config.problem_type == "regression":
									snake_case_						:	Optional[Any]      =		MSELoss()
									if self.num_labels == 1:
										snake_case_						:	str      =		loss_fct(logits.squeeze()						,      labels.squeeze()		)
									else:
										snake_case_						:	str      =		loss_fct(_A						,      _A		)
								elif self.config.problem_type == "single_label_classification":
									snake_case_						:	List[str]      =		CrossEntropyLoss()
									snake_case_						:	Union[str, Any]      =		loss_fct(logits.view(-1						,      self.num_labels		)						,      labels.view(-1		)		)
								elif self.config.problem_type == "multi_label_classification":
									snake_case_						:	Tuple      =		BCEWithLogitsLoss()
									snake_case_						:	Optional[Any]      =		loss_fct(_A						,      _A		)

							if not return_dict:
								snake_case_						:	int      =		(logits,) + outputs[2:]
								return ((loss,) + output) if loss is not None else output

							return ImageClassifierOutputWithNoAttention(
							    loss=_A						,      logits=_A						,      hidden_states=outputs.hidden_states						,      )








import os
from itertools import chain
from random import randrange, shuffle

import pytest

from .sola import PokerHand

lowerCAmelCase_    =				(
    '''4S 3H 2C 7S 5H''',
    '''9D 8H 2C 6S 7H''',
    '''2D 6D 9D TH 7D''',
    '''TC 8C 2S JH 6C''',
    '''JH 8S TH AH QH''',
    '''TS KS 5S 9S AC''',
    '''KD 6S 9D TH AD''',
    '''KS 8D 4D 9S 4S''',  # pair
    '''8C 4S KH JS 4D''',  # pair
    '''QH 8H KD JH 8S''',  # pair
    '''KC 4H KS 2H 8D''',  # pair
    '''KD 4S KC 3H 8S''',  # pair
    '''AH 8S AS KC JH''',  # pair
    '''3H 4C 4H 3S 2H''',  # 2 pairs
    '''5S 5D 2C KH KH''',  # 2 pairs
    '''3C KH 5D 5S KH''',  # 2 pairs
    '''AS 3C KH AD KH''',  # 2 pairs
    '''7C 7S 3S 7H 5S''',  # 3 of a kind
    '''7C 7S KH 2H 7H''',  # 3 of a kind
    '''AC KH QH AH AS''',  # 3 of a kind
    '''2H 4D 3C AS 5S''',  # straight (low ace)
    '''3C 5C 4C 2C 6H''',  # straight
    '''6S 8S 7S 5H 9H''',  # straight
    '''JS QS 9H TS KH''',  # straight
    '''QC KH TS JS AH''',  # straight (high ace)
    '''8C 9C 5C 3C TC''',  # flush
    '''3S 8S 9S 5S KS''',  # flush
    '''4C 5C 9C 8C KC''',  # flush
    '''JH 8H AH KH QH''',  # flush
    '''3D 2H 3H 2C 2D''',  # full house
    '''2H 2C 3S 3H 3D''',  # full house
    '''KH KC 3S 3H 3D''',  # full house
    '''JC 6H JS JD JH''',  # 4 of a kind
    '''JC 7H JS JD JH''',  # 4 of a kind
    '''JC KH JS JD JH''',  # 4 of a kind
    '''2S AS 4S 5S 3S''',  # straight flush (low ace)
    '''2D 6D 3D 4D 5D''',  # straight flush
    '''5C 6C 3C 7C 4C''',  # straight flush
    '''JH 9H TH KH QH''',  # straight flush
    '''JH AH TH KH QH''',  # royal flush (high ace straight flush)
)

lowerCAmelCase_    =				(
    ('''2H 3H 4H 5H 6H''', '''KS AS TS QS JS''', '''Loss'''),
    ('''2H 3H 4H 5H 6H''', '''AS AD AC AH JD''', '''Win'''),
    ('''AS AH 2H AD AC''', '''JS JD JC JH 3D''', '''Win'''),
    ('''2S AH 2H AS AC''', '''JS JD JC JH AD''', '''Loss'''),
    ('''2S AH 2H AS AC''', '''2H 3H 5H 6H 7H''', '''Win'''),
    ('''AS 3S 4S 8S 2S''', '''2H 3H 5H 6H 7H''', '''Win'''),
    ('''2H 3H 5H 6H 7H''', '''2S 3H 4H 5S 6C''', '''Win'''),
    ('''2S 3H 4H 5S 6C''', '''3D 4C 5H 6H 2S''', '''Tie'''),
    ('''2S 3H 4H 5S 6C''', '''AH AC 5H 6H AS''', '''Win'''),
    ('''2S 2H 4H 5S 4C''', '''AH AC 5H 6H AS''', '''Loss'''),
    ('''2S 2H 4H 5S 4C''', '''AH AC 5H 6H 7S''', '''Win'''),
    ('''6S AD 7H 4S AS''', '''AH AC 5H 6H 7S''', '''Loss'''),
    ('''2S AH 4H 5S KC''', '''AH AC 5H 6H 7S''', '''Loss'''),
    ('''2S 3H 6H 7S 9C''', '''7H 3C TH 6H 9S''', '''Loss'''),
    ('''4S 5H 6H TS AC''', '''3S 5H 6H TS AC''', '''Win'''),
    ('''2S AH 4H 5S 6C''', '''AD 4C 5H 6H 2C''', '''Tie'''),
    ('''AS AH 3H AD AC''', '''AS AH 2H AD AC''', '''Win'''),
    ('''AH AC 5H 5C QS''', '''AH AC 5H 5C KS''', '''Loss'''),
    ('''AH AC 5H 5C QS''', '''KH KC 5H 5C QS''', '''Win'''),
    ('''7C 7S KH 2H 7H''', '''3C 3S AH 2H 3H''', '''Win'''),
    ('''3C 3S AH 2H 3H''', '''7C 7S KH 2H 7H''', '''Loss'''),
    ('''6H 5H 4H 3H 2H''', '''5H 4H 3H 2H AH''', '''Win'''),
    ('''5H 4H 3H 2H AH''', '''5H 4H 3H 2H AH''', '''Tie'''),
    ('''5H 4H 3H 2H AH''', '''6H 5H 4H 3H 2H''', '''Loss'''),
    ('''AH AD KS KC AC''', '''AH KD KH AC KC''', '''Win'''),
    ('''2H 4D 3C AS 5S''', '''2H 4D 3C 6S 5S''', '''Loss'''),
    ('''2H 3S 3C 3H 2S''', '''3S 3C 2S 2H 2D''', '''Win'''),
    ('''4D 6D 5D 2D JH''', '''3S 8S 3H TC KH''', '''Loss'''),
    ('''4S 6C 8S 3S 7S''', '''AD KS 2D 7D 7C''', '''Loss'''),
    ('''6S 4C 7H 8C 3H''', '''5H JC AH 9D 9C''', '''Loss'''),
    ('''9D 9H JH TC QH''', '''3C 2S JS 5C 7H''', '''Win'''),
    ('''2H TC 8S AD 9S''', '''4H TS 7H 2C 5C''', '''Win'''),
    ('''9D 3S 2C 7S 7C''', '''JC TD 3C TC 9H''', '''Loss'''),
)

lowerCAmelCase_    =				(
    ('''2H 3H 4H 5H 6H''', True),
    ('''AS AH 2H AD AC''', False),
    ('''2H 3H 5H 6H 7H''', True),
    ('''KS AS TS QS JS''', True),
    ('''8H 9H QS JS TH''', False),
    ('''AS 3S 4S 8S 2S''', True),
)

lowerCAmelCase_    =				(
    ('''2H 3H 4H 5H 6H''', True),
    ('''AS AH 2H AD AC''', False),
    ('''2H 3H 5H 6H 7H''', False),
    ('''KS AS TS QS JS''', True),
    ('''8H 9H QS JS TH''', True),
)

lowerCAmelCase_    =				(
    ('''2H 4D 3C AS 5S''', True, [5, 4, 3, 2, 1_4]),
    ('''2H 5D 3C AS 5S''', False, [1_4, 5, 5, 3, 2]),
    ('''JH QD KC AS TS''', False, [1_4, 1_3, 1_2, 1_1, 1_0]),
    ('''9D 3S 2C 7S 7C''', False, [9, 7, 7, 3, 2]),
)

lowerCAmelCase_    =				(
    ('''JH AH TH KH QH''', 0),
    ('''JH 9H TH KH QH''', 0),
    ('''JC KH JS JD JH''', 7),
    ('''KH KC 3S 3H 3D''', 6),
    ('''8C 9C 5C 3C TC''', 0),
    ('''JS QS 9H TS KH''', 0),
    ('''7C 7S KH 2H 7H''', 3),
    ('''3C KH 5D 5S KH''', 2),
    ('''QH 8H KD JH 8S''', 1),
    ('''2D 6D 9D TH 7D''', 0),
)

lowerCAmelCase_    =				(
    ('''JH AH TH KH QH''', 2_3),
    ('''JH 9H TH KH QH''', 2_2),
    ('''JC KH JS JD JH''', 2_1),
    ('''KH KC 3S 3H 3D''', 2_0),
    ('''8C 9C 5C 3C TC''', 1_9),
    ('''JS QS 9H TS KH''', 1_8),
    ('''7C 7S KH 2H 7H''', 1_7),
    ('''3C KH 5D 5S KH''', 1_6),
    ('''QH 8H KD JH 8S''', 1_5),
    ('''2D 6D 9D TH 7D''', 1_4),
)






def      lowerCamelCase_						(				)		->						Dict:






				"""simple docstring"""


				snake_case_			,							snake_case_						:    Any				=  randrange(len(_UpperCamelCase ) ), randrange(len(_UpperCamelCase ) )
				snake_case_						:    Any				=  ['''Loss''', '''Tie''', '''Win'''][(play >= oppo) + (play > oppo)]
				snake_case_			,							snake_case_						:    Tuple				=  SORTED_HANDS[play], SORTED_HANDS[oppo]
				return hand, other, expected






def      lowerCamelCase_						(				_UpperCamelCase = 100 )		->						str:






				"""simple docstring"""


				return (generate_random_hand() for _ in range(_UpperCamelCase ))






@pytest.mark.parametrize('''hand, expected''' ,				_UpperCamelCase )
def      lowerCamelCase_						(				_UpperCamelCase ,				_UpperCamelCase )		->						int:






				"""simple docstring"""


				assert PokerHand(_UpperCamelCase )._is_flush() == expected






@pytest.mark.parametrize('''hand, expected''' ,				_UpperCamelCase )
def      lowerCamelCase_						(				_UpperCamelCase ,				_UpperCamelCase )		->						Optional[int]:






				"""simple docstring"""


				assert PokerHand(_UpperCamelCase )._is_straight() == expected






@pytest.mark.parametrize('''hand, expected, card_values''' ,				_UpperCamelCase )
def      lowerCamelCase_						(				_UpperCamelCase ,				_UpperCamelCase ,				_UpperCamelCase )		->						Tuple:






				"""simple docstring"""


				snake_case_						:    str				=  PokerHand(_UpperCamelCase )
				assert player._is_five_high_straight() == expected
				assert player._card_values == card_values






@pytest.mark.parametrize('''hand, expected''' ,				_UpperCamelCase )
def      lowerCamelCase_						(				_UpperCamelCase ,				_UpperCamelCase )		->						int:






				"""simple docstring"""


				assert PokerHand(_UpperCamelCase )._is_same_kind() == expected






@pytest.mark.parametrize('''hand, expected''' ,				_UpperCamelCase )
def      lowerCamelCase_						(				_UpperCamelCase ,				_UpperCamelCase )		->						Optional[int]:






				"""simple docstring"""


				assert PokerHand(_UpperCamelCase )._hand_type == expected






@pytest.mark.parametrize('''hand, other, expected''' ,				_UpperCamelCase )
def      lowerCamelCase_						(				_UpperCamelCase ,				_UpperCamelCase ,				_UpperCamelCase )		->						Any:






				"""simple docstring"""


				assert PokerHand(_UpperCamelCase ).compare_with(PokerHand(_UpperCamelCase ) ) == expected






@pytest.mark.parametrize('''hand, other, expected''' ,				generate_random_hands() )
def      lowerCamelCase_						(				_UpperCamelCase ,				_UpperCamelCase ,				_UpperCamelCase )		->						Optional[Any]:






				"""simple docstring"""


				assert PokerHand(_UpperCamelCase ).compare_with(PokerHand(_UpperCamelCase ) ) == expected






def      lowerCamelCase_						(				)		->						str:






				"""simple docstring"""


				snake_case_						:    Dict				=  [PokerHand(_UpperCamelCase ) for hand in SORTED_HANDS]
				snake_case_						:    str				=  poker_hands.copy()
				shuffle(_UpperCamelCase )
				snake_case_						:    List[str]				=  chain(sorted(_UpperCamelCase ) )
				for index, hand in enumerate(_UpperCamelCase ):
								assert hand == poker_hands[index]






def      lowerCamelCase_						(				)		->						Dict:






				"""simple docstring"""


				snake_case_						:    Union[str, Any]				=  [PokerHand('''2D AC 3H 4H 5S''' ), PokerHand('''2S 3H 4H 5S 6C''' )]
				pokerhands.sort(reverse=_UpperCamelCase )
				assert pokerhands[0].__str__() == "2S 3H 4H 5S 6C"






def      lowerCamelCase_						(				)		->						str:






				"""simple docstring"""


				snake_case_						:    Dict				=  PokerHand('''2C 4S AS 3D 5C''' )
				snake_case_						:    str				=  True
				snake_case_						:    Tuple				=  [5, 4, 3, 2, 14]
				for _ in range(10 ):
								assert pokerhand._is_five_high_straight() == expected
								assert pokerhand._card_values == expected_card_values






def      lowerCamelCase_						(				)		->						List[str]:






				"""simple docstring"""


				snake_case_						:    List[str]				=  0
				snake_case_						:    Union[str, Any]				=  os.path.abspath(os.path.dirname(_UpperCamelCase ) )
				snake_case_						:    Dict				=  os.path.join(_UpperCamelCase ,				'''poker_hands.txt''' )
				with open(_UpperCamelCase ) as file_hand:
								for line in file_hand:
												snake_case_						:    Dict				=  line[:14].strip()
												snake_case_						:    List[str]				=  line[15:].strip()
												snake_case_			,							snake_case_						:    str				=  PokerHand(_UpperCamelCase ), PokerHand(_UpperCamelCase )
												snake_case_						:    int				=  player.compare_with(_UpperCamelCase )
												if output == "Win":
																answer += 1
				assert answer == 376
