





'''simple docstring'''






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


A__    :       Dict              =False




class 			UpperCAmelCase					(      unittest.TestCase       ):
      pass




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




      def     lowercase__   (      self      :			str  )    ->				List[str]:
            _lowerCAmelCase												=							VersatileDiffusionImageVariationPipeline.from_pretrained("""shi-labs/versatile-diffusion"""  )
            pipe.to(__snake_case  )
            pipe.set_progress_bar_config(disable=__snake_case  )

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

            _lowerCAmelCase												=							image[0, 2_53:2_56, 2_53:2_56, -1]

            assert image.shape == (1, 5_12, 5_12, 3)
            _lowerCAmelCase												=							np.array([0.04_41, 0.04_69, 0.05_07, 0.05_75, 0.06_32, 0.06_50, 0.08_65, 0.09_09, 0.09_45]  )

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













'''simple docstring'''






def        UpperCamelCase__				(		lowerCAmelCase							,     lowerCAmelCase  ):





      """simple docstring"""


      if not (isinstance(lowerCAmelCase							,     lowerCAmelCase  ) and isinstance(lowerCAmelCase							,     lowerCAmelCase  )):
            raise ValueError("""longest_common_substring() takes two strings for inputs"""  )

      _lowerCAmelCase												=							len(lowerCAmelCase  )
      _lowerCAmelCase												=							len(lowerCAmelCase  )

      _lowerCAmelCase												=							[[0] * (texta_length + 1) for _ in range(texta_length + 1  )]
      _lowerCAmelCase												=							0
      _lowerCAmelCase												=							0

      for i in range(1							,     texta_length + 1  ):
            for j in range(1							,     texta_length + 1  ):
                  if texta[i - 1] == texta[j - 1]:
                        _lowerCAmelCase												=							1 + dp[i - 1][j - 1]
                        if dp[i][j] > ans_length:
                              _lowerCAmelCase												=							i
                              _lowerCAmelCase												=							dp[i][j]

      return texta[ans_index - ans_length : ans_index]


if __name__ == "__main__":
      import doctest

      doctest.testmod()






