




UpperCamelCase__              =						(1, 1_5_3, 3_7_0, 3_7_1, 1_6_3_4, 2_4_6_7_8_0_5_1, 1_1_5_1_3_2_2_1_9_0_1_8_7_6_3_9_9_2_5_6_5_0_9_5_5_9_7_9_7_3_9_7_1_5_2_2_4_0_1)
UpperCamelCase__              =						(-1_5_3, -1, 0, 1.2, 2_0_0, "A", [], {}, None)






def 					snake_case					(							A			)							->							bool:




	'''simple docstring'''


	if not isinstance(A						,   A			) or n < 1:
		return False

	# Initialization of sum and number of digits.
	lowerCamelCase_							:		Optional[int]							   =							0
	lowerCamelCase_							:		List[Any]							   =							0
	lowerCamelCase_							:		Dict							   =							n
	# Calculation of digits of the number
	while temp > 0:
		number_of_digits += 1
		temp //= 10
	# Dividing number into separate digits and find Armstrong number
	lowerCamelCase_							:		List[Any]							   =							n
	while temp > 0:
		lowerCamelCase_							:		Union[str, Any]							   =							temp % 10
		total += rem**number_of_digits
		temp //= 10
	return n == total






def 					snake_case					(							A			)							->							bool:




	'''simple docstring'''


	if not isinstance(A						,   A			) or n < 1:
		return False

	# Init a "histogram" of the digits
	lowerCamelCase_							:		Optional[Any]							   =							[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	lowerCamelCase_							:		int							   =							0
	lowerCamelCase_							:		List[str]							   =							0
	lowerCamelCase_							:		Tuple							   =							n
	while temp > 0:
		lowerCamelCase_   ,			lowerCamelCase_							:		List[str]							   =							divmod(A						,   10			)
		digit_histogram[rem] += 1
		digit_total += 1

	for cnt, i in zip(A						,   range(len(A			)			)			):
		total += cnt * i**digit_total

	return n == total






def 					snake_case					(							A			)							->							bool:




	'''simple docstring'''


	if not isinstance(A						,   A			) or n < 1:
		return False
	lowerCamelCase_							:		str							   =							len(str(A			)			)  # the power that all digits will be raised to
	# check if sum of each digit multiplied expo times is equal to number
	return n == sum(int(A			) ** expo for i in str(A			)			)






def 					snake_case					(							)							->							str:




	'''simple docstring'''


	lowerCamelCase_							:		int							   =							int(input('Enter an integer to see if it is an Armstrong number: '			).strip()			)
	print(f"{num} is {'' if armstrong_number(A			) else 'not '}an Armstrong number."			)
	print(f"{num} is {'' if narcissistic_number(A			) else 'not '}an Armstrong number."			)
	print(f"{num} is {'' if pluperfect_number(A			) else 'not '}an Armstrong number."			)


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							main()



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  __lowerCamelCase				(	unittest.TestCase	):
      lowerCamelCase_	:      Tuple          =					MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING
      lowerCamelCase_	:      int          =					TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING







      def 	lowerCAmelCase_    (     self							,  lowerCamelCase							,  lowerCamelCase							,  lowerCamelCase   )						->       Any:
        if isinstance(model.config							,  lowerCamelCase   ):
          snake_case_						,				snake_case_       						=      list(tokenizer.lang_code_to_id.keys()   )[:2]
          snake_case_       						=      TranslationPipeline(model=lowerCamelCase							,  tokenizer=lowerCamelCase							,  src_lang=lowerCamelCase							,  tgt_lang=lowerCamelCase   )
        else:
          snake_case_       						=      TranslationPipeline(model=lowerCamelCase							,  tokenizer=lowerCamelCase   )
        return translator, ["Some string", "Some other text"]







      def 	lowerCAmelCase_    (     self							,  lowerCamelCase							,  lowerCamelCase   )						->       List[str]:
        snake_case_       						=      translator("""Some string"""   )
        self.assertEqual(lowerCamelCase							,  [{"""translation_text""": ANY(lowerCamelCase   )}]   )

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

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







      @require_torch
      def 	lowerCAmelCase_    (     self   )						->       List[Any]:
        snake_case_       						=      pipeline("""translation_en_to_ro"""							,  model="""patrickvonplaten/t5-tiny-random"""							,  framework="""pt"""   )
        snake_case_       						=      translator("""This is a test string"""							,  max_length=20   )
        self.assertEqual(
            lowerCamelCase							,  [
                {
                    """translation_text""": (
                        """Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide"""
                        """ Beide Beide"""
                    )
                }
            ]							,  )







      @require_tf
      def 	lowerCAmelCase_    (     self   )						->       Optional[Any]:
        snake_case_       						=      pipeline("""translation_en_to_ro"""							,  model="""patrickvonplaten/t5-tiny-random"""							,  framework="""tf"""   )
        snake_case_       						=      translator("""This is a test string"""							,  max_length=20   )
        self.assertEqual(
            lowerCamelCase							,  [
                {
                    """translation_text""": (
                        """Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide"""
                        """ Beide Beide"""
                    )
                }
            ]							,  )







      @require_torch
      def 	lowerCAmelCase_    (     self   )						->       Union[str, Any]:
        snake_case_       						=      pipeline("""translation_en_to_de"""							,  model="""patrickvonplaten/t5-tiny-random"""							,  framework="""pt"""   )
        snake_case_       						=      translator("""This is a test string"""							,  max_length=20   )
        self.assertEqual(
            lowerCamelCase							,  [
                {
                    """translation_text""": (
                        """monoton monoton monoton monoton monoton monoton monoton monoton monoton monoton urine urine"""
                        """ urine urine urine urine urine urine urine"""
                    )
                }
            ]							,  )







      @require_tf
      def 	lowerCAmelCase_    (     self   )						->       List[Any]:
        snake_case_       						=      pipeline("""translation_en_to_de"""							,  model="""patrickvonplaten/t5-tiny-random"""							,  framework="""tf"""   )
        snake_case_       						=      translator("""This is a test string"""							,  max_length=20   )
        self.assertEqual(
            lowerCamelCase							,  [
                {
                    """translation_text""": (
                        """monoton monoton monoton monoton monoton monoton monoton monoton monoton monoton urine urine"""
                        """ urine urine urine urine urine urine urine"""
                    )
                }
            ]							,  )







class  __lowerCamelCase				(	unittest.TestCase	):







      @require_torch
      @slow
      def 	lowerCAmelCase_    (     self   )						->       Tuple:
        # We don't provide a default for this pair
        with self.assertRaises(lowerCamelCase   ):
          pipeline(task="""translation_cn_to_ar"""   )

        # but we do for this one
        snake_case_       						=      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 	lowerCAmelCase_    (     self   )						->       int:
        snake_case_       						=      MBartForConditionalGeneration.from_pretrained("""facebook/mbart-large-50-many-to-many-mmt"""   )
        snake_case_       						=      MBartaaTokenizerFast.from_pretrained("""facebook/mbart-large-50-many-to-many-mmt"""   )

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

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

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

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







      @require_torch
      def 	lowerCAmelCase_    (     self   )						->       int:
        snake_case_       						=      """patrickvonplaten/t5-tiny-random"""
        snake_case_       						=      pipeline(task="""translation_cn_to_ar"""							,  model=lowerCamelCase   )
        self.assertEqual(translator._preprocess_params["""src_lang"""]							,  """cn"""   )
        self.assertEqual(translator._preprocess_params["""tgt_lang"""]							,  """ar"""   )







      @require_torch
      def 	lowerCAmelCase_    (     self   )						->       List[str]:
        snake_case_       						=      """patrickvonplaten/t5-tiny-random"""
        with pytest.warns(lowerCamelCase							,  match=r""".*translation_en_to_de.*"""   ):
          snake_case_       						=      pipeline(task="""translation"""							,  model=lowerCamelCase   )
        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 	lowerCAmelCase_    (     self   )						->       Any:
        with self.assertRaises(lowerCamelCase   ):
          pipeline(task="""translation"""   )