






"""simple docstring"""



import unittest

from transformers import (
    MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING,
    TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING,
    TextaTextGenerationPipeline,
    pipeline,
)
from transformers.testing_utils import is_pipeline_test, require_tf, require_torch
from transformers.utils import is_torch_available

from .test_pipelines_common import ANY


if is_torch_available():
						import torch





@is_pipeline_test
class 					_UpperCAmelCase       ( unittest.TestCase							):
					SCREAMING_SNAKE_CASE_		:				Optional[Any]							    =   MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING
					SCREAMING_SNAKE_CASE_		:				Any							    =   TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING




					def   A  (				self     :						str    ,						A     :						Union[str, Any]    ,						A     :						Union[str, Any]    ,						A     :						str   )  ->  List[Any]:
							lowercase_ : Union[str, Any]							       =   TextaTextGenerationPipeline(model=lowerCAmelCase__    ,						tokenizer=lowerCAmelCase__   )
							return generator, ["Something to write", "Something else"]




					def   A  (				self     :						Optional[int]    ,						A     :						Any    ,						A     :						Dict   )  ->  List[Any]:
							lowercase_ : List[str]							       =   generator('''Something there'''   )
							self.assertEqual(lowerCAmelCase__    ,						[{'''generated_text''': ANY(lowerCAmelCase__   )}]   )
							# These are encoder decoder, they don't just append to incoming string
							self.assertFalse(outputs[0]['''generated_text'''].startswith('''Something there'''   )   )

							lowercase_ : int							       =   generator(['''This is great !''', '''Something else''']    ,						num_return_sequences=2    ,						do_sample=lowerCAmelCase__   )
							self.assertEqual(
							    lowerCAmelCase__    ,						[
							        [{'''generated_text''': ANY(lowerCAmelCase__   )}, {'''generated_text''': ANY(lowerCAmelCase__   )}],
							        [{'''generated_text''': ANY(lowerCAmelCase__   )}, {'''generated_text''': ANY(lowerCAmelCase__   )}],
							    ]    ,						)

							lowercase_ : List[Any]							       =   generator(
							    ['''This is great !''', '''Something else''']    ,						num_return_sequences=2    ,						batch_size=2    ,						do_sample=lowerCAmelCase__   )
							self.assertEqual(
							    lowerCAmelCase__    ,						[
							        [{'''generated_text''': ANY(lowerCAmelCase__   )}, {'''generated_text''': ANY(lowerCAmelCase__   )}],
							        [{'''generated_text''': ANY(lowerCAmelCase__   )}, {'''generated_text''': ANY(lowerCAmelCase__   )}],
							    ]    ,						)

							with self.assertRaises(lowerCAmelCase__   ):
									generator(4   )




					@require_torch
					def   A  (				self     :						int   )  ->  Optional[int]:
							lowercase_ : Any							       =   pipeline('''text2text-generation'''    ,						model='''patrickvonplaten/t5-tiny-random'''    ,						framework='''pt'''   )
							# do_sample=False necessary for reproducibility
							lowercase_ : Dict							       =   generator('''Something there'''    ,						do_sample=lowerCAmelCase__   )
							self.assertEqual(lowerCAmelCase__    ,						[{'''generated_text''': ''''''}]   )

							lowercase_ : int							       =   3
							lowercase_ : str							       =   generator(
							    '''Something there'''    ,						num_return_sequences=lowerCAmelCase__    ,						num_beams=lowerCAmelCase__    ,						)
							lowercase_ : int							       =   [
							    {'''generated_text''': '''Beide Beide Beide Beide Beide Beide Beide Beide Beide'''},
							    {'''generated_text''': '''Beide Beide Beide Beide Beide Beide Beide Beide'''},
							    {'''generated_text''': ''''''},
							]
							self.assertEqual(lowerCAmelCase__    ,						lowerCAmelCase__   )

							lowercase_ : Any							       =   generator('''This is a test'''    ,						do_sample=lowerCAmelCase__    ,						num_return_sequences=2    ,						return_tensors=lowerCAmelCase__   )
							self.assertEqual(
							    lowerCAmelCase__    ,						[
							        {'''generated_token_ids''': ANY(torch.Tensor   )},
							        {'''generated_token_ids''': ANY(torch.Tensor   )},
							    ]    ,						)
							lowercase_ : Tuple							       =   generator.model.config.eos_token_id
							lowercase_ : List[Any]							       =   '''<pad>'''
							lowercase_ : int							       =   generator(
							    ['''This is a test''', '''This is a second test''']    ,						do_sample=lowerCAmelCase__    ,						num_return_sequences=2    ,						batch_size=2    ,						return_tensors=lowerCAmelCase__    ,						)
							self.assertEqual(
							    lowerCAmelCase__    ,						[
							        [
							            {'''generated_token_ids''': ANY(torch.Tensor   )},
							            {'''generated_token_ids''': ANY(torch.Tensor   )},
							        ],
							        [
							            {'''generated_token_ids''': ANY(torch.Tensor   )},
							            {'''generated_token_ids''': ANY(torch.Tensor   )},
							        ],
							    ]    ,						)






					@require_tf
					def   A  (				self     :						Optional[Any]   )  ->  List[str]:
							lowercase_ : int							       =   pipeline('''text2text-generation'''    ,						model='''patrickvonplaten/t5-tiny-random'''    ,						framework='''tf'''   )
							# do_sample=False necessary for reproducibility
							lowercase_ : str							       =   generator('''Something there'''    ,						do_sample=lowerCAmelCase__   )
							self.assertEqual(lowerCAmelCase__    ,						[{'''generated_text''': ''''''}]   )





"""simple docstring"""





from __future__ import annotations

from fractions import Fraction



def 						_lowerCAmelCase				(				UpperCamelCase_  ,				UpperCamelCase_				):
		return (
		    num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den
		)



def 						_lowerCAmelCase				(				UpperCamelCase_				):
		__SCREAMING_SNAKE_CASE            = []
		__SCREAMING_SNAKE_CASE            = 11
		__SCREAMING_SNAKE_CASE            = int("""1""" + """0""" * digit_len				)
		for num in range(UpperCamelCase_  ,				UpperCamelCase_				):
				while den <= 99:
						if (num != den) and (num % 10 == den // 10) and (den % 10 != 0):
								if is_digit_cancelling(UpperCamelCase_  ,				UpperCamelCase_				):
										solutions.append(f"{num}/{den}"				)
						den += 1
				num += 1
				__SCREAMING_SNAKE_CASE            = 10
		return solutions



def 						_lowerCAmelCase				(				UpperCamelCase_ = 2				):
		__SCREAMING_SNAKE_CASE            = 1.0
		for fraction in fraction_list(UpperCamelCase_				):
				__SCREAMING_SNAKE_CASE            = Fraction(UpperCamelCase_				)
				result *= frac.denominator / frac.numerator
		return int(UpperCamelCase_				)


if __name__ == "__main__":
							print(solution())




