




'''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_      :  Union[str, Any]				     =  False







class      SCREAMING_SNAKE_CASE    (						unittest.TestCase				):
      pass







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






      def 							lowercase_						( self   :  int       ):


           '''simple docstring'''

           a_     :							List[str]     						=  VersatileDiffusionImageVariationPipeline.from_pretrained("""shi-labs/versatile-diffusion"""       )
           pipe.to(lowercase__       )
           pipe.set_progress_bar_config(disable=lowercase__       )

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

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

           assert image.shape == (1, 512, 512, 3)
           a_     :							Optional[Any]     						=  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






'''simple docstring'''


import math
import random



def  _SCREAMING_SNAKE_CASE     (      UpperCamelCase__    :					float ,    UpperCamelCase__    :					bool = False				):




     """simple docstring"""


     if deriv:
          return value * (1 - value)
     return 1 / (1 + math.exp(-value				))


# Initial Value
lowerCAmelCase_      :  Optional[Any]				     =  0.02



def  _SCREAMING_SNAKE_CASE     (      UpperCamelCase__    :					int ,    UpperCamelCase__    :					int				):




     """simple docstring"""


     a_     :							Tuple     						=  float(2 * (random.randint(1 ,    100				)) - 1				)

     for _ in range(UpperCamelCase__				):
          # Forward propagation
          a_     :							Dict     						=  sigmoid_function(INITIAL_VALUE * weight				)
          # How much did we miss?
          a_     :							Dict     						=  (expected / 100) - layer_a
          # Error delta
          a_     :							Optional[Any]     						=  layer_1_error * sigmoid_function(UpperCamelCase__ ,    UpperCamelCase__				)
          # Update weight
          weight += INITIAL_VALUE * layer_1_delta

     return layer_a * 100


if __name__ == "__main__":
 import doctest

 doctest.testmod()

 lowerCAmelCase_      :  str				     =  int(input('Expected value: '))
 lowerCAmelCase_      :  str				     =  int(input('Number of propagations: '))
 print(forward_propagation(expected, number_propagations))
