

import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionImageVariationPipeline
from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device


_SCREAMING_SNAKE_CASE					:  Union[str, Any]             =      False






class 	UpperCAmelCase__		(	unittest.TestCase	):






  """simple docstring"""


  pass






@slow
@require_torch_gpu
class 	UpperCAmelCase__		(	unittest.TestCase	):






  """simple docstring"""


  def 				lowercase_		(							self						:		Optional[int] )		->							Dict:
       SCREAMING_SNAKE_CASE__   =   VersatileDiffusionImageVariationPipeline.from_pretrained('''shi-labs/versatile-diffusion''' )
       pipe.to(__lowerCamelCase )
       pipe.set_progress_bar_config(disable=__lowerCamelCase )

       SCREAMING_SNAKE_CASE__   =   load_image(
           '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg''' )
       SCREAMING_SNAKE_CASE__   =   torch.manual_seed(0 )
       SCREAMING_SNAKE_CASE__   =   pipe(
           image=__lowerCamelCase     ,       generator=__lowerCamelCase     ,       guidance_scale=7.5     ,       num_inference_steps=50     ,       output_type='''numpy'''     ,       ).images

       SCREAMING_SNAKE_CASE__   =   image[0, 253:256, 253:256, -1]

       assert image.shape == (1, 512, 512, 3)
       SCREAMING_SNAKE_CASE__   =   np.array([0.0441, 0.0469, 0.0507, 0.0575, 0.0632, 0.0650, 0.0865, 0.0909, 0.0945] )

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





import doctest
from collections import deque

import numpy as np






class 	UpperCAmelCase__		:






  """simple docstring"""


  def __init__(							self						:		List[Any] )		->							None:
       SCREAMING_SNAKE_CASE__   =   [2, 1, 2, -1]
       SCREAMING_SNAKE_CASE__   =   [1, 2, 3, 4]







  def 				lowercase_		(							self						:		Optional[int] )		->							list[float]:
       SCREAMING_SNAKE_CASE__   =   len(self.first_signal )
       SCREAMING_SNAKE_CASE__   =   len(self.second_signal )

       SCREAMING_SNAKE_CASE__   =   max(__lowerCamelCase     ,       __lowerCamelCase )

       # create a zero matrix of max_length x max_length
       SCREAMING_SNAKE_CASE__   =   [[0] * max_length for i in range(__lowerCamelCase )]

       # fills the smaller signal with zeros to make both signals of same length
       if length_first_signal < length_second_signal:
            self.first_signal += [0] * (max_length - length_first_signal)
       elif length_first_signal > length_second_signal:
            self.second_signal += [0] * (max_length - length_second_signal)
       for i in range(__lowerCamelCase ):
            SCREAMING_SNAKE_CASE__   =   deque(self.second_signal )
            rotated_signal.rotate(__lowerCamelCase )
            for j, item in enumerate(__lowerCamelCase ):
                 matrix[i][j] += item

        # multiply the matrix with the first signal
       SCREAMING_SNAKE_CASE__   =   np.matmul(np.transpose(__lowerCamelCase )     ,       np.transpose(self.first_signal ) )

       # rounding-off to two decimal places
       return [round(__lowerCamelCase     ,       2 ) for i in final_signal]


if __name__ == "__main__":
       doctest.testmod()


