




'''simple docstring'''



UpperCamelCase_    	=				[4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5]
UpperCamelCase_    	=				[3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5]
UpperCamelCase_    	=				{
    0: """Sunday""",
    1: """Monday""",
    2: """Tuesday""",
    3: """Wednesday""",
    4: """Thursday""",
    5: """Friday""",
    6: """Saturday""",
}




def   lowercase__(			__UpperCamelCase:					Dict      ,__UpperCamelCase:					Optional[int]      ,__UpperCamelCase:					List[Any]    ):

      """simple docstring"""






      assert len(str(__UpperCamelCase    )    ) > 2, "year should be in YYYY format"
      assert 1 <= month <= 12, "month should be between 1 to 12"
      assert 1 <= day <= 31, "day should be between 1 to 31"

      # Doomsday algorithm:
      SCREAMING_SNAKE_CASE   :      List[str]    					=						year // 1_00
      SCREAMING_SNAKE_CASE   :      Any    					=						(5 * (century % 4) + 2) % 7
      SCREAMING_SNAKE_CASE   :      Tuple    					=						year % 1_00
      SCREAMING_SNAKE_CASE   :      Optional[int]    					=						centurian % 12
      SCREAMING_SNAKE_CASE   :      str    					=						(
          (centurian // 12) + centurian_m + (centurian_m // 4) + century_anchor
      ) % 7
      SCREAMING_SNAKE_CASE   :      Dict    					=						(
          DOOMSDAY_NOT_LEAP[month - 1]
          if (year % 4 != 0) or (centurian == 0 and (year % 4_00) == 0)
          else DOOMSDAY_LEAP[month - 1]
      )
      SCREAMING_SNAKE_CASE   :      int    					=						(dooms_day + day - day_anchor) % 7
      return WEEK_DAY_NAMES[week_day]


if __name__ == "__main__":
      import doctest

      doctest.testmod()



import gc
import tempfile
import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionTextToImagePipeline
from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device


a  :      List[str]            =    False

class 					_lowercase    (     unittest.TestCase			):






    '''simple docstring'''
    pass





@nightly
@require_torch_gpu
class 					_lowercase    (     unittest.TestCase			):






    '''simple docstring'''




    def      _a    (    self ):
       # clean up the VRAM after each test
       super().tearDown()
       gc.collect()
       torch.cuda.empty_cache()




    def      _a    (    self ):
       lowerCAmelCase_:							List[str]       =	VersatileDiffusionTextToImagePipeline.from_pretrained("shi-labs/versatile-diffusion" )
       # remove text_unet
       pipe.remove_unused_weights()
       pipe.to(lowerCamelCase__ )
       pipe.set_progress_bar_config(disable=lowerCamelCase__ )

       lowerCAmelCase_:							Tuple       =	"A painting of a squirrel eating a burger "
       lowerCAmelCase_:							List[str]       =	torch.manual_seed(0 )
       lowerCAmelCase_:							Dict       =	pipe(
           prompt=lowerCamelCase__       ,						generator=lowerCamelCase__       ,						guidance_scale=7.5       ,						num_inference_steps=2       ,						output_type="numpy" ).images

       with tempfile.TemporaryDirectory() as tmpdirname:
          pipe.save_pretrained(lowerCamelCase__ )
          lowerCAmelCase_:							int       =	VersatileDiffusionTextToImagePipeline.from_pretrained(lowerCamelCase__ )
       pipe.to(lowerCamelCase__ )
       pipe.set_progress_bar_config(disable=lowerCamelCase__ )

       lowerCAmelCase_:							List[str]       =	generator.manual_seed(0 )
       lowerCAmelCase_:							Dict       =	pipe(
           prompt=lowerCamelCase__       ,						generator=lowerCamelCase__       ,						guidance_scale=7.5       ,						num_inference_steps=2       ,						output_type="numpy" ).images

       assert np.abs(image - new_image ).sum() < 1E-5, "Models don't have the same forward pass"




    def      _a    (    self ):
       lowerCAmelCase_:							Optional[int]       =	VersatileDiffusionTextToImagePipeline.from_pretrained(
           "shi-labs/versatile-diffusion"       ,						torch_dtype=torch.floataa )
       pipe.to(lowerCamelCase__ )
       pipe.set_progress_bar_config(disable=lowerCamelCase__ )

       lowerCAmelCase_:							str       =	"A painting of a squirrel eating a burger "
       lowerCAmelCase_:							int       =	torch.manual_seed(0 )
       lowerCAmelCase_:							List[str]       =	pipe(
           prompt=lowerCamelCase__       ,						generator=lowerCamelCase__       ,						guidance_scale=7.5       ,						num_inference_steps=50       ,						output_type="numpy" ).images

       lowerCAmelCase_:							List[Any]       =	image[0, 253:256, 253:256, -1]

       assert image.shape == (1, 512, 512, 3)
       lowerCAmelCase_:							Optional[int]       =	np.array([0.3_3_6_7, 0.3_1_6_9, 0.2_6_5_6, 0.3_8_7_0, 0.4_7_9_0, 0.3_7_9_6, 0.4_0_0_9, 0.4_8_7_8, 0.4_7_7_8] )

       assert np.abs(image_slice.flatten() - expected_slice ).max() < 1E-2