
"""simple docstring"""




import gc
import tempfile
import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionDualGuidedPipeline
from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device


a		:					str    	=					False







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



     def  lowercase__(       self      )		->    Any:







         """simple docstring"""



         super().tearDown()
         gc.collect()
         torch.cuda.empty_cache()



     def  lowercase__(       self      )		->    Optional[int]:







         """simple docstring"""



         a__    = VersatileDiffusionDualGuidedPipeline.from_pretrained('shi-labs/versatile-diffusion'      )
         # remove text_unet
         pipe.remove_unused_weights()
         pipe.to(__SCREAMING_SNAKE_CASE      )
         pipe.set_progress_bar_config(disable=__SCREAMING_SNAKE_CASE      )

         a__    = load_image(
             'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg'      )

         a__    = torch.manual_seed(0      )
         a__    = pipe(
             prompt='first prompt'    ,							image=__SCREAMING_SNAKE_CASE    ,							text_to_image_strength=0.75    ,							generator=__SCREAMING_SNAKE_CASE    ,							guidance_scale=7.5    ,							num_inference_steps=2    ,							output_type='numpy'    ,							).images

         with tempfile.TemporaryDirectory() as tmpdirname:
             pipe.save_pretrained(__SCREAMING_SNAKE_CASE      )
             a__    = VersatileDiffusionDualGuidedPipeline.from_pretrained(__SCREAMING_SNAKE_CASE      )

         pipe.to(__SCREAMING_SNAKE_CASE      )
         pipe.set_progress_bar_config(disable=__SCREAMING_SNAKE_CASE      )

         a__    = generator.manual_seed(0      )
         a__    = pipe(
             prompt='first prompt'    ,							image=__SCREAMING_SNAKE_CASE    ,							text_to_image_strength=0.75    ,							generator=__SCREAMING_SNAKE_CASE    ,							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  lowercase__(       self      )		->    Union[str, Any]:







         """simple docstring"""



         a__    = VersatileDiffusionDualGuidedPipeline.from_pretrained('shi-labs/versatile-diffusion'      )
         pipe.remove_unused_weights()
         pipe.to(__SCREAMING_SNAKE_CASE      )
         pipe.set_progress_bar_config(disable=__SCREAMING_SNAKE_CASE      )

         a__    = 'cyberpunk 2077'
         a__    = load_image(
             'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg'      )
         a__    = torch.manual_seed(0      )
         a__    = pipe(
             prompt=__SCREAMING_SNAKE_CASE    ,							image=__SCREAMING_SNAKE_CASE    ,							text_to_image_strength=0.75    ,							generator=__SCREAMING_SNAKE_CASE    ,							guidance_scale=7.5    ,							num_inference_steps=5_0    ,							output_type='numpy'    ,							).images

         a__    = image[0, 2_5_3:2_5_6, 2_5_3:2_5_6, -1]

         assert image.shape == (1, 5_1_2, 5_1_2, 3)
         a__    = np.array([0.07_87, 0.08_49, 0.08_26, 0.08_12, 0.08_07, 0.07_95, 0.08_18, 0.07_98, 0.07_79]      )

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




"""simple docstring"""




a		:					str    	=					(1, 1_53, 3_70, 3_71, 16_34, 24_67_80_51, 1_15_13_22_19_01_87_63_99_25_65_09_55_97_97_39_71_52_24_01)
a		:					tuple    	=					(-1_53, -1, 0, 1.2, 2_00, "A", [], {}, None)



def 						__magic_name__		(				UpperCamelCase    :		int    )    ->	bool:
    if not isinstance(UpperCamelCase       ,		UpperCamelCase    ) or n < 1:
        return False

    # Initialization of sum and number of digits.
    a__    = 0
    a__    = 0
    a__    = n
    # Calculation of digits of the number
    while temp > 0:
        number_of_digits += 1
        temp //= 10
    # Dividing number into separate digits and find Armstrong number
    a__    = n
    while temp > 0:
        a__    = temp % 10
        total += rem**number_of_digits
        temp //= 10
    return n == total



def 						__magic_name__		(				UpperCamelCase    :		int    )    ->	bool:
    if not isinstance(UpperCamelCase       ,		UpperCamelCase    ) or n < 1:
        return False

    # Init a "histogram" of the digits
    a__    = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    a__    = 0
    a__    = 0
    a__    = n
    while temp > 0:
        a__  ,    a__    = divmod(UpperCamelCase       ,		10    )
        digit_histogram[rem] += 1
        digit_total += 1

    for cnt, i in zip(UpperCamelCase       ,		range(len(UpperCamelCase    )    )    ):
        total += cnt * i**digit_total

    return n == total



def 						__magic_name__		(				UpperCamelCase    :		int    )    ->	bool:
    if not isinstance(UpperCamelCase       ,		UpperCamelCase    ) or n < 1:
        return False
    a__    = len(str(UpperCamelCase    )    )  # the power that all digits will be raised to
    # check if sum of each digit multiplied expo times is equal to number
    return n == sum(int(UpperCamelCase    ) ** expo for i in str(UpperCamelCase    )    )



def 						__magic_name__		(				)    ->	List[Any]:
    a__    = int(input('Enter an integer to see if it is an Armstrong number: '    ).strip()    )
    print(f'{num} is {"" if armstrong_number(UpperCamelCase    ) else "not "}an Armstrong number.'    )
    print(f'{num} is {"" if narcissistic_number(UpperCamelCase    ) else "not "}an Armstrong number.'    )
    print(f'{num} is {"" if pluperfect_number(UpperCamelCase    ) else "not "}an Armstrong number.'    )


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    main()


