





"""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 		__snake_case (		unittest.TestCase					):





 """simple docstring"""


 _lowerCamelCase				=					MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING
 _lowerCamelCase				=					TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING

 def  UpperCamelCase__(   self ,						__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase  ):



     '''simple docstring'''




     __A   :						int									=					TextaTextGenerationPipeline(model=__lowerCamelCase ,						tokenizer=__lowerCamelCase  )
     return generator, ["Something to write", "Something else"]

 def  UpperCamelCase__(   self ,						__lowerCamelCase ,						__lowerCamelCase  ):



     '''simple docstring'''




     __A   :						Any									=					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'''  )  )

     __A   :						Optional[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  )}],
         ] ,						)

     __A   :						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  UpperCamelCase__(   self  ):



     '''simple docstring'''




     __A   :						Dict									=					pipeline('''text2text-generation''' ,						model='''patrickvonplaten/t5-tiny-random''' ,						framework='''pt'''  )
     # do_sample=False necessary for reproducibility
     __A   :						int									=					generator('''Something there''' ,						do_sample=__lowerCamelCase  )
     self.assertEqual(__lowerCamelCase ,						[{'''generated_text''': ''''''}]  )

     __A   :						str									=					3
     __A   :						int									=					generator(
         '''Something there''' ,						num_return_sequences=__lowerCamelCase ,						num_beams=__lowerCamelCase ,						)
     __A   :						Any									=					[
         {"""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  )

     __A   :						List[str]									=					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  )},
         ] ,						)
     __A   :						Any									=					generator.model.config.eos_token_id
     __A   :						Any									=					"""<pad>"""
     __A   :						Optional[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  UpperCamelCase__(   self  ):



     '''simple docstring'''




     __A   :						int									=					pipeline('''text2text-generation''' ,						model='''patrickvonplaten/t5-tiny-random''' ,						framework='''tf'''  )
     # do_sample=False necessary for reproducibility
     __A   :						List[Any]									=					generator('''Something there''' ,						do_sample=__lowerCamelCase  )
     self.assertEqual(__lowerCamelCase ,						[{'''generated_text''': ''''''}]  )











"""simple docstring"""



def 		__lowercase					(       )       ->Tuple:



    '''simple docstring'''







    __A   :						str									=					[]
    __A   :						List[Any]									=					1

    while len(snake_case_						) < 1e6:
        constant.append(str(snake_case_						)						)
        i += 1

    __A   :						Any									=					''''''.join(snake_case_						)

    return (
        int(constant[0]						)
        * int(constant[9]						)
        * int(constant[99]						)
        * int(constant[999]						)
        * int(constant[9999]						)
        * int(constant[99999]						)
        * int(constant[999999]						)
    )


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




