






'''simple docstring'''


from __future__ import annotations

import unittest

from transformers import OpenAIGPTConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
					import tensorflow as tf

					from transformers.models.openai.modeling_tf_openai import (
					    TF_OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST,
					    TFOpenAIGPTDoubleHeadsModel,
					    TFOpenAIGPTForSequenceClassification,
					    TFOpenAIGPTLMHeadModel,
					    TFOpenAIGPTModel,
					)
class  _SCREAMING_SNAKE_CASE				:


			'''simple docstring'''





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

									'''simple docstring'''







									UpperCamelCase__       =			parent
									UpperCamelCase__       =			1_3
									UpperCamelCase__       =			7
									UpperCamelCase__       =			True
									UpperCamelCase__       =			True
									UpperCamelCase__       =			True
									UpperCamelCase__       =			True
									UpperCamelCase__       =			True
									UpperCamelCase__       =			9_9
									UpperCamelCase__       =			3_2
									UpperCamelCase__       =			2
									UpperCamelCase__       =			4
									UpperCamelCase__       =			3_7
									UpperCamelCase__       =			"""gelu"""
									UpperCamelCase__       =			0.1
									UpperCamelCase__       =			0.1
									UpperCamelCase__       =			5_1_2
									UpperCamelCase__       =			1_6
									UpperCamelCase__       =			2
									UpperCamelCase__       =			0.0_2
									UpperCamelCase__       =			3
									UpperCamelCase__       =			4
									UpperCamelCase__       =			None
									UpperCamelCase__       =			self.vocab_size - 1






			def 					A   ( self				:    Optional[Any]      )				->     Any:

									'''simple docstring'''







									UpperCamelCase__       =			ids_tensor([self.batch_size, self.seq_length]			,   self.vocab_size      )

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

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

									UpperCamelCase__       =			None
									if self.use_mc_token_ids:
															UpperCamelCase__       =			ids_tensor([self.batch_size, self.num_choices]			,   self.seq_length      )

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

									UpperCamelCase__       =			OpenAIGPTConfig(
									    vocab_size=self.vocab_size			,   n_embd=self.hidden_size			,   n_layer=self.num_hidden_layers			,   n_head=self.num_attention_heads			,   n_positions=self.max_position_embeddings			,   pad_token_id=self.pad_token_id			,   )

									UpperCamelCase__       =			ids_tensor([self.num_hidden_layers, self.num_attention_heads]			,   2      )

									return (
									    config,
									    input_ids,
									    input_mask,
									    head_mask,
									    token_type_ids,
									    mc_token_ids,
									    sequence_labels,
									    token_labels,
									    choice_labels,
									)






			def 					A   ( self				:    int			,   lowercase				:    Optional[int]			,   lowercase				:    Union[str, Any]			,   lowercase				:    Tuple			,   lowercase				:    Optional[int]			,   lowercase				:    List[str]			,   *lowercase				:    Optional[Any]      )				->     int:

									'''simple docstring'''







									UpperCamelCase__       =			TFOpenAIGPTModel(config=lowercase      )
									UpperCamelCase__       =			{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
									UpperCamelCase__       =			model(lowercase      )

									UpperCamelCase__       =			[input_ids, input_mask]
									UpperCamelCase__       =			model(lowercase      )

									UpperCamelCase__       =			model(lowercase      )

									self.parent.assertEqual(result.last_hidden_state.shape			,   (self.batch_size, self.seq_length, self.hidden_size)      )






			def 					A   ( self				:    str			,   lowercase				:    Optional[int]			,   lowercase				:    str			,   lowercase				:    Dict			,   lowercase				:    Union[str, Any]			,   lowercase				:    Union[str, Any]			,   *lowercase				:    Union[str, Any]      )				->     Tuple:

									'''simple docstring'''







									UpperCamelCase__       =			TFOpenAIGPTLMHeadModel(config=lowercase      )
									UpperCamelCase__       =			{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
									UpperCamelCase__       =			model(lowercase      )
									self.parent.assertEqual(result.logits.shape			,   (self.batch_size, self.seq_length, self.vocab_size)      )






			def 					A   ( self				:    Union[str, Any]			,   lowercase				:    List[Any]			,   lowercase				:    Any			,   lowercase				:    Union[str, Any]			,   lowercase				:    Any			,   lowercase				:    Tuple			,   lowercase				:    int			,   *lowercase				:    Dict      )				->     List[Any]:

									'''simple docstring'''







									UpperCamelCase__       =			TFOpenAIGPTDoubleHeadsModel(config=lowercase      )

									UpperCamelCase__       =			tf.tile(tf.expand_dims(lowercase			,   1      )			,   (1, self.num_choices, 1)      )
									UpperCamelCase__       =			tf.tile(tf.expand_dims(lowercase			,   1      )			,   (1, self.num_choices, 1)      )
									UpperCamelCase__       =			tf.tile(tf.expand_dims(lowercase			,   1      )			,   (1, self.num_choices, 1)      )

									UpperCamelCase__       =			{
									    """input_ids""": multiple_choice_inputs_ids,
									    """mc_token_ids""": mc_token_ids,
									    """attention_mask""": multiple_choice_input_mask,
									    """token_type_ids""": multiple_choice_token_type_ids,
									}
									UpperCamelCase__       =			model(lowercase      )
									self.parent.assertEqual(
									    result.logits.shape			,   (self.batch_size, self.num_choices, self.seq_length, self.vocab_size)      )
									self.parent.assertEqual(result.mc_logits.shape			,   (self.batch_size, self.num_choices)      )






			def 					A   ( self				:    Optional[Any]			,   lowercase				:    int			,   lowercase				:    Any			,   lowercase				:    Optional[int]			,   lowercase				:    Optional[Any]			,   lowercase				:    List[str]			,   *lowercase				:    Union[str, Any]      )				->     Dict:

									'''simple docstring'''







									UpperCamelCase__       =			self.num_labels
									UpperCamelCase__       =			ids_tensor([self.batch_size]			,   self.type_sequence_label_size      )
									UpperCamelCase__       =			{
									    """input_ids""": input_ids,
									    """attention_mask""": input_mask,
									    """token_type_ids""": token_type_ids,
									    """labels""": sequence_labels,
									}
									UpperCamelCase__       =			TFOpenAIGPTForSequenceClassification(lowercase      )
									UpperCamelCase__       =			model(lowercase      )
									self.parent.assertEqual(result.logits.shape			,   (self.batch_size, self.num_labels)      )







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

									'''simple docstring'''







									UpperCamelCase__       =			self.prepare_config_and_inputs()

									(
									    (
									    UpperCamelCase__
									)     , (
									    UpperCamelCase__
									)     , (
									    UpperCamelCase__
									)     , (
									    UpperCamelCase__
									)     , (
									    UpperCamelCase__
									)     , (
									    UpperCamelCase__
									)     , (
									    UpperCamelCase__
									)     , (
									    UpperCamelCase__
									)     , (
									    UpperCamelCase__
									)     , 
									)       =			config_and_inputs

									UpperCamelCase__       =			{"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
									return config, inputs_dict
@require_tf
class  _SCREAMING_SNAKE_CASE				(		SCREAMING_SNAKE_CASE							,SCREAMING_SNAKE_CASE							,unittest.TestCase						):


			'''simple docstring'''





			__a				:				int         =       (
			    (TFOpenAIGPTModel, TFOpenAIGPTLMHeadModel, TFOpenAIGPTDoubleHeadsModel, TFOpenAIGPTForSequenceClassification)
			    if is_tf_available()
			    else ()
			)
			__a				:				List[str]         =       (
			    (TFOpenAIGPTLMHeadModel,) if is_tf_available() else ()
			)  # TODO (PVP): Add Double HeadsModel when generate() function is changed accordingly
			__a				:				Any         =       (
			    {
			        "feature-extraction": TFOpenAIGPTModel,
			        "text-classification": TFOpenAIGPTForSequenceClassification,
			        "text-generation": TFOpenAIGPTLMHeadModel,
			        "zero-shot": TFOpenAIGPTForSequenceClassification,
			    }
			    if is_tf_available()
			    else {}
			)
			__a				:				int         =       False
			__a				:				str         =       False






			def 					A   ( self				:    List[Any]			,   lowercase				:    Dict			,   lowercase				:    str			,   lowercase				:    Union[str, Any]			,   lowercase				:    Optional[int]			,   lowercase				:    Optional[Any]      )				->     int:

									'''simple docstring'''







									if pipeline_test_casse_name == "ZeroShotClassificationPipelineTests":
															# Get `tokenizer does not have a padding token` error for both fast/slow tokenizers.
															# `OpenAIGPTConfig` was never used in pipeline tests, either because of a missing checkpoint or because a
															# tiny config could not be created.
															return True

									return False






			def 					A   ( self				:    Tuple      )				->     int:

									'''simple docstring'''







									UpperCamelCase__       =			TFOpenAIGPTModelTester(self      )
									UpperCamelCase__       =			ConfigTester(self			,   config_class=lowercase			,   n_embd=3_7      )






			def 					A   ( self				:    Dict      )				->     Optional[int]:

									'''simple docstring'''







									self.config_tester.run_common_tests()






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

									'''simple docstring'''







									UpperCamelCase__       =			self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_openai_gpt_model(*lowercase      )






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

									'''simple docstring'''







									UpperCamelCase__       =			self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_openai_gpt_lm_head(*lowercase      )






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

									'''simple docstring'''







									UpperCamelCase__       =			self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_openai_gpt_double_head(*lowercase      )






			def 					A   ( self				:    Any      )				->     str:

									'''simple docstring'''







									UpperCamelCase__       =			self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_openai_gpt_for_sequence_classification(*lowercase      )







			@slow
			def 					A   ( self				:    str      )				->     Dict:

									'''simple docstring'''







									for model_name in TF_OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															UpperCamelCase__       =			TFOpenAIGPTModel.from_pretrained(lowercase      )
															self.assertIsNotNone(lowercase      )
@require_tf
class  _SCREAMING_SNAKE_CASE				(		unittest.TestCase						):


			'''simple docstring'''





			@slow
			def 					A   ( self				:    Tuple      )				->     Union[str, Any]:

									'''simple docstring'''







									UpperCamelCase__       =			TFOpenAIGPTLMHeadModel.from_pretrained("""openai-gpt"""      )
									UpperCamelCase__       =			tf.convert_to_tensor([[4_8_1, 4_7_3_5, 5_4_4]]			,   dtype=tf.intaa      )  # the president is
									UpperCamelCase__       =			[
									    4_8_1,
									    4_7_3_5,
									    5_4_4,
									    2_4_6,
									    9_6_3,
									    8_7_0,
									    7_6_2,
									    2_3_9,
									    2_4_4,
									    4_0_4_7_7,
									    2_4_4,
									    2_4_9,
									    7_1_9,
									    8_8_1,
									    4_8_7,
									    5_4_4,
									    2_4_0,
									    2_4_4,
									    6_0_3,
									    4_8_1,
									]  # the president is a very good man. " \n " i\'m sure he is, " said the

									UpperCamelCase__       =			model.generate(lowercase			,   do_sample=lowercase      )
									self.assertListEqual(output_ids[0].numpy().tolist()			,   lowercase      )








'''simple docstring'''


from itertools import combinations_with_replacement







def 						__magic_name__(			_A = 100       ):
						'''simple docstring'''





						UpperCamelCase__       =			[*list(range(1    ,   21       )       ), 25]
						UpperCamelCase__       =			[2 * x for x in range(1    ,   21       )] + [50]
						UpperCamelCase__       =			[3 * x for x in range(1    ,   21       )]
						UpperCamelCase__       =			singles + doubles + triples + [0]

						UpperCamelCase__       =			0
						UpperCamelCase__       =			42
						UpperCamelCase__       =			42
						UpperCamelCase__       =			42
						UpperCamelCase__       =			42

						for double in doubles:
												for throwa, throwa in combinations_with_replacement(_A    ,   2       ):
																		UpperCamelCase__       =			double + throwa + throwa
																		if checkout_total < limit:
																								num_checkouts += 1

						return num_checkouts


if __name__ == "__main__":
					print(f"""{solution() = }""")
