






'''simple docstring'''
from collections.abc import Callable

import numpy as np





def        _a(     UpperCamelCase__ :  Callable,		UpperCamelCase__ :  float,		UpperCamelCase__ :  float,		UpperCamelCase__ :  float,		UpperCamelCase__ :  float							):




      '''simple docstring'''






      SCREAMING_SNAKE_CASE__   : List[str]													=int(np.ceil((x_end - xa) / step_size							)							)
      SCREAMING_SNAKE_CASE__   : Union[str, Any]													=np.zeros((n + 1,)							)
      SCREAMING_SNAKE_CASE__   : Dict													=ya
      SCREAMING_SNAKE_CASE__   : Optional[int]													=xa

      for k in range(_UpperCamelCase							):
            SCREAMING_SNAKE_CASE__   : List[str]													=y[k] + step_size * ode_func(_UpperCamelCase,		y[k]							)
            SCREAMING_SNAKE_CASE__   : Dict													=y[k] + (
                (step_size / 2) * (ode_func(_UpperCamelCase,		y[k]							) + ode_func(x + step_size,		_UpperCamelCase							))
            )
            x += step_size

      return y


if __name__ == "__main__":
  import doctest

  doctest.testmod()


'''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


lowerCamelCase :      Optional[int]					 =     False







class 							A__    (       unittest.TestCase  ):
  pass







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





  def 						A  (		self      :	Tuple )	->    Dict:





       '''simple docstring'''






       _SCREAMING_SNAKE_CASE							    =VersatileDiffusionImageVariationPipeline.from_pretrained('shi-labs/versatile-diffusion' )
       pipe.to(_a )
       pipe.set_progress_bar_config(disable=_a )

       _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=_a							,					generator=_a							,					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.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
