






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



  def     A_					(self	:		List[str] )		->				Optional[int]:
   __A						:							int      =						'runwayml/stable-diffusion-v1-5'
   __A						:							int      =						TextToVideoZeroPipeline.from_pretrained(lowercase_					,      torch_dtype=torch.floataa ).to('cuda' )
   __A						:							str      =						DDIMScheduler.from_config(pipe.scheduler.config )
   __A						:							str      =						torch.Generator(device='cuda' ).manual_seed(0 )

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

   __A						:							Any      =						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(lowercase_					,      lowercase_ )













"""simple docstring"""


import importlib.metadata
import subprocess
import sys




def 					a			(  UpperCamelCase_				:					bool = False		)	->		Optional[Any]:
 __A						:							List[Any]      =						False
 if "IPython" in sys.modules:
  __A						:							List[Any]      =						'google.colab' in str(sys.modules['IPython'].get_ipython()		)

 if in_colab:
  if upgrade:
   __A						:							Dict      =						['pip', 'install', '-U', 'torch']
   subprocess.run(UpperCamelCase_  ,						check=UpperCamelCase_		)
  # get the current version of torch
  __A						:							int      =						importlib.metadata.version('torch'		)
  __A						:							int      =						torch_version[: torch_version.rindex('.'		)]
  __A						:							Any      =						F"https://storage.googleapis.com/tpu-pytorch/wheels/colab/torch_xla-{torch_version_trunc}-cp37-cp37m-linux_x86_64.whl"
  __A						:							int      =						['pip', 'install', xla_wheel]
  subprocess.run(UpperCamelCase_  ,						check=UpperCamelCase_		)
 else:
  raise RuntimeError('`install_xla` utility works only on google colab.'		)





