






"""simple docstring"""


from transformers.models.cpm.tokenization_cpm import CpmTokenizer
from transformers.testing_utils import custom_tokenizers

from ..xlnet.test_modeling_xlnet import XLNetModelTest




@custom_tokenizers
class 	__UpperCamelCase    (    UpperCamelCase	):
					def 					UpperCAmelCase__   (       self       :  int    ,   UpperCAmelCase       :  Tuple    ,   UpperCAmelCase       :  str    ,   UpperCAmelCase       :  List[Any]    ,   UpperCAmelCase       :  Tuple    ,   UpperCAmelCase       :  List[Any]      )  ->					List[str]:
											return True
					def 					UpperCAmelCase__   (       self       :  Optional[int]      )  ->					Optional[Any]:
											lowerCAmelCase      :Union[str, Any]				  = CpmTokenizer.from_pretrained('TsinghuaAI/CPM-Generate'      )
											lowerCAmelCase      :str				  = 'Hugging Face大法好，谁用谁知道。'
											lowerCAmelCase      :Union[str, Any]				  = 'Hugging Face大法好,谁用谁知道。<unk>'
											lowerCAmelCase      :List[Any]				  = '▁Hu gg ing ▁ ▂ ▁F ace ▁大法 ▁好 ▁ , ▁谁 ▁用 ▁谁 ▁知 道 ▁ 。'.split()

											lowerCAmelCase      :Union[str, Any]				  = tokenizer.tokenize(UpperCAmelCase      )
											self.assertListEqual(UpperCAmelCase    ,   UpperCAmelCase      )

											lowerCAmelCase      :Optional[Any]				  = tokens + [tokenizer.unk_token]

											lowerCAmelCase      :Optional[Any]				  = [1_3789, 1_3283, 1421, 8, 10, 1164, 1_3608, 1_6528, 63, 8, 9, 440, 108, 440, 121, 90, 8, 12, 0]
											self.assertListEqual(tokenizer.convert_tokens_to_ids(UpperCAmelCase      )    ,   UpperCAmelCase      )

											lowerCAmelCase      :Union[str, Any]				  = tokenizer.decode(UpperCAmelCase      )
											self.assertEqual(UpperCAmelCase    ,   UpperCAmelCase      )







"""simple docstring"""


import unittest

import torch

from diffusers import DDIMScheduler, TextToVideoZeroPipeline
from diffusers.utils import load_pt, require_torch_gpu, slow

from ..test_pipelines_common import assert_mean_pixel_difference




@slow
@require_torch_gpu
class 	__UpperCamelCase    (    unittest.TestCase	):
					def 					UpperCAmelCase__   (       self       :  Union[str, Any]      )  ->					Optional[Any]:
											lowerCAmelCase      :Union[str, Any]				  = 'runwayml/stable-diffusion-v1-5'
											lowerCAmelCase      :Tuple				  = TextToVideoZeroPipeline.from_pretrained(UpperCAmelCase    ,   torch_dtype=torch.floataa      ).to('cuda'      )
											lowerCAmelCase      :Union[str, Any]				  = DDIMScheduler.from_config(pipe.scheduler.config      )
											lowerCAmelCase      :str				  = torch.Generator(device='cuda'      ).manual_seed(0      )

											lowerCAmelCase      :Any				  = 'A bear is playing a guitar on Times Square'
											lowerCAmelCase      :Optional[Any]				  = pipe(prompt=UpperCAmelCase    ,   generator=UpperCAmelCase      ).images

											lowerCAmelCase      :List[str]				  = load_pt(
											    'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/text-to-video/A bear is playing a guitar on Times Square.pt'      )

											assert_mean_pixel_difference(UpperCAmelCase    ,   UpperCAmelCase      )