






import unittest

import pytest

from transformers import (
    MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING,
    TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING,
    MBartaaTokenizerFast,
    MBartConfig,
    MBartForConditionalGeneration,
    TranslationPipeline,
    pipeline,
)
from transformers.testing_utils import is_pipeline_test, require_tf, require_torch, slow

from .test_pipelines_common import ANY


@is_pipeline_test
class        lowercase__       (     unittest.TestCase		):
	a_             =MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING
	a_             =TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING

	def 						UpperCAmelCase					(							self						,      __UpperCAmelCase						,      __UpperCAmelCase						,      __UpperCAmelCase    )->   List[str]:







							'''simple docstring'''





							if isinstance(model.config						,      __UpperCAmelCase    ):
													lowerCAmelCase__ ,							lowerCAmelCase__	 =  list(tokenizer.lang_code_to_id.keys()    )[:2]
													lowerCAmelCase__	 =  TranslationPipeline(model=__UpperCAmelCase						,      tokenizer=__UpperCAmelCase						,      src_lang=__UpperCAmelCase						,      tgt_lang=__UpperCAmelCase    )
							else:
													lowerCAmelCase__	 =  TranslationPipeline(model=__UpperCAmelCase						,      tokenizer=__UpperCAmelCase    )
							return translator, ["Some string", "Some other text"]

	def 						UpperCAmelCase					(							self						,      __UpperCAmelCase						,      __UpperCAmelCase    )->   Dict:







							'''simple docstring'''





							lowerCAmelCase__	 =  translator("Some string"    )
							self.assertEqual(__UpperCAmelCase						,      [{"translation_text": ANY(__UpperCAmelCase    )}]    )

							lowerCAmelCase__	 =  translator(["Some string"]    )
							self.assertEqual(__UpperCAmelCase						,      [{"translation_text": ANY(__UpperCAmelCase    )}]    )

							lowerCAmelCase__	 =  translator(["Some string", "other string"]    )
							self.assertEqual(__UpperCAmelCase						,      [{"translation_text": ANY(__UpperCAmelCase    )}, {"translation_text": ANY(__UpperCAmelCase    )}]    )

	@require_torch
	def 						UpperCAmelCase					(							self    )->   Union[str, Any]:







							'''simple docstring'''





							lowerCAmelCase__	 =  pipeline("translation_en_to_ro"						,      model="patrickvonplaten/t5-tiny-random"						,      framework="pt"    )
							lowerCAmelCase__	 =  translator("This is a test string"						,      max_length=20    )
							self.assertEqual(
							    __UpperCAmelCase						,      [
							        {
							            "translation_text": (
							                "Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide"
							                " Beide Beide"
							            )
							        }
							    ]						,      )

	@require_tf
	def 						UpperCAmelCase					(							self    )->   int:







							'''simple docstring'''





							lowerCAmelCase__	 =  pipeline("translation_en_to_ro"						,      model="patrickvonplaten/t5-tiny-random"						,      framework="tf"    )
							lowerCAmelCase__	 =  translator("This is a test string"						,      max_length=20    )
							self.assertEqual(
							    __UpperCAmelCase						,      [
							        {
							            "translation_text": (
							                "Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide"
							                " Beide Beide"
							            )
							        }
							    ]						,      )

	@require_torch
	def 						UpperCAmelCase					(							self    )->   int:







							'''simple docstring'''





							lowerCAmelCase__	 =  pipeline("translation_en_to_de"						,      model="patrickvonplaten/t5-tiny-random"						,      framework="pt"    )
							lowerCAmelCase__	 =  translator("This is a test string"						,      max_length=20    )
							self.assertEqual(
							    __UpperCAmelCase						,      [
							        {
							            "translation_text": (
							                "monoton monoton monoton monoton monoton monoton monoton monoton monoton monoton urine urine"
							                " urine urine urine urine urine urine urine"
							            )
							        }
							    ]						,      )


	@require_tf
	def 						UpperCAmelCase					(							self    )->   Optional[Any]:







							'''simple docstring'''





							lowerCAmelCase__	 =  pipeline("translation_en_to_de"						,      model="patrickvonplaten/t5-tiny-random"						,      framework="tf"    )
							lowerCAmelCase__	 =  translator("This is a test string"						,      max_length=20    )
							self.assertEqual(
							    __UpperCAmelCase						,      [
							        {
							            "translation_text": (
							                "monoton monoton monoton monoton monoton monoton monoton monoton monoton monoton urine urine"
							                " urine urine urine urine urine urine urine"
							            )
							        }
							    ]						,      )





class        lowercase__       (     unittest.TestCase		):

	@require_torch
	@slow
	def 						UpperCAmelCase					(							self    )->   Optional[int]:







							'''simple docstring'''





							with self.assertRaises(__UpperCAmelCase    ):
													pipeline(task="translation_cn_to_ar"    )

							# but we do for this one
							lowerCAmelCase__	 =  pipeline(task="translation_en_to_de"    )
							self.assertEqual(translator._preprocess_params["src_lang"]						,      "en"    )
							self.assertEqual(translator._preprocess_params["tgt_lang"]						,      "de"    )

	@require_torch
	@slow
	def 						UpperCAmelCase					(							self    )->   List[str]:







							'''simple docstring'''





							lowerCAmelCase__	 =  MBartForConditionalGeneration.from_pretrained("facebook/mbart-large-50-many-to-many-mmt"    )
							lowerCAmelCase__	 =  MBartaaTokenizerFast.from_pretrained("facebook/mbart-large-50-many-to-many-mmt"    )

							lowerCAmelCase__	 =  pipeline(task="translation"						,      model=__UpperCAmelCase						,      tokenizer=__UpperCAmelCase    )
							# Missing src_lang, tgt_lang
							with self.assertRaises(__UpperCAmelCase    ):
													translator("This is a test"    )

							lowerCAmelCase__	 =  translator("This is a test"						,      src_lang="en_XX"						,      tgt_lang="ar_AR"    )
							self.assertEqual(__UpperCAmelCase						,      [{"translation_text": "هذا إختبار"}]    )

							lowerCAmelCase__	 =  translator("This is a test"						,      src_lang="en_XX"						,      tgt_lang="hi_IN"    )
							self.assertEqual(__UpperCAmelCase						,      [{"translation_text": "यह एक परीक्षण है"}]    )

							# src_lang, tgt_lang can be defined at pipeline call time
							lowerCAmelCase__	 =  pipeline(task="translation"						,      model=__UpperCAmelCase						,      tokenizer=__UpperCAmelCase						,      src_lang="en_XX"						,      tgt_lang="ar_AR"    )
							lowerCAmelCase__	 =  translator("This is a test"    )
							self.assertEqual(__UpperCAmelCase						,      [{"translation_text": "هذا إختبار"}]    )

	@require_torch
	def 						UpperCAmelCase					(							self    )->   Dict:







							'''simple docstring'''





							lowerCAmelCase__	 =  "patrickvonplaten/t5-tiny-random"
							lowerCAmelCase__	 =  pipeline(task="translation_cn_to_ar"						,      model=__UpperCAmelCase    )
							self.assertEqual(translator._preprocess_params["src_lang"]						,      "cn"    )
							self.assertEqual(translator._preprocess_params["tgt_lang"]						,      "ar"    )

	@require_torch
	def 						UpperCAmelCase					(							self    )->   Optional[Any]:







							'''simple docstring'''





							lowerCAmelCase__	 =  "patrickvonplaten/t5-tiny-random"
							with pytest.warns(__UpperCAmelCase						,      match=R".*translation_en_to_de.*"    ):
													lowerCAmelCase__	 =  pipeline(task="translation"						,      model=__UpperCAmelCase    )
							self.assertEqual(translator.task						,      "translation_en_to_de"    )
							self.assertEqual(translator._preprocess_params["src_lang"]						,      "en"    )
							self.assertEqual(translator._preprocess_params["tgt_lang"]						,      "de"    )


	@require_torch
	def 						UpperCAmelCase					(							self    )->   List[str]:







							'''simple docstring'''





							with self.assertRaises(__UpperCAmelCase    ):
													pipeline(task="translation"    )














def     _a					(       UpperCamelCase_   :			int = 100				)	->				int:
						"""simple docstring"""







						lowerCAmelCase__	 =  1
						lowerCAmelCase__	 =  0
						for i in range(1      ,				num + 1				):
												fact *= i

						for j in str(UpperCamelCase_				):
												result += int(UpperCamelCase_				)

						return result


if __name__ == "__main__":
	print(solution(int(input('''Enter the Number: ''').strip())))






