


'''simple docstring'''





import random
import unittest

import numpy as np
import torch

from diffusers import DDIMScheduler, LDMSuperResolutionPipeline, UNetaDModel, VQModel
from diffusers.utils import PIL_INTERPOLATION, floats_tensor, load_image, slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch


enable_full_determinism()




class 							UpperCAmelCase ( unittest.TestCase	):


 @property
 def 					__SCREAMING_SNAKE_CASE				(			self       :  Tuple   ):
    UpperCAmelCase__  :Optional[int]            =			1
    UpperCAmelCase__  :Dict            =			3
    UpperCAmelCase__  :List[Any]            =			(3_2, 3_2)

    UpperCAmelCase__  :Optional[Any]            =			floats_tensor((batch_size, num_channels) + sizes ,					rng=random.Random(0   )   ).to(__lowerCamelCase   )
    return image


 @property
 def 					__SCREAMING_SNAKE_CASE				(			self       :  Optional[Any]   ):
    torch.manual_seed(0   )
    UpperCAmelCase__  :Optional[Any]            =			UNetaDModel(
        block_out_channels=(3_2, 6_4) ,					layers_per_block=2 ,					sample_size=3_2 ,					in_channels=6 ,					out_channels=3 ,					down_block_types=('''DownBlock2D''', '''AttnDownBlock2D''') ,					up_block_types=('''AttnUpBlock2D''', '''UpBlock2D''') ,					)
    return model


 @property
 def 					__SCREAMING_SNAKE_CASE				(			self       :  Any   ):
    torch.manual_seed(0   )
    UpperCAmelCase__  :int            =			VQModel(
        block_out_channels=[3_2, 6_4] ,					in_channels=3 ,					out_channels=3 ,					down_block_types=['''DownEncoderBlock2D''', '''DownEncoderBlock2D'''] ,					up_block_types=['''UpDecoderBlock2D''', '''UpDecoderBlock2D'''] ,					latent_channels=3 ,					)
    return model


 def 					__SCREAMING_SNAKE_CASE				(			self       :  List[Any]   ):
    UpperCAmelCase__  :Optional[Any]            =			'''cpu'''
    UpperCAmelCase__  :List[Any]            =			self.dummy_uncond_unet
    UpperCAmelCase__  :Optional[int]            =			DDIMScheduler()
    UpperCAmelCase__  :Tuple            =			self.dummy_vq_model

    UpperCAmelCase__  :Any            =			LDMSuperResolutionPipeline(unet=__lowerCamelCase ,					vqvae=__lowerCamelCase ,					scheduler=__lowerCamelCase   )
    ldm.to(__lowerCamelCase   )
    ldm.set_progress_bar_config(disable=__lowerCamelCase   )

    UpperCAmelCase__  :Optional[Any]            =			self.dummy_image.to(__lowerCamelCase   )

    UpperCAmelCase__  :List[Any]            =			torch.Generator(device=__lowerCamelCase   ).manual_seed(0   )
    UpperCAmelCase__  :int            =			ldm(image=__lowerCamelCase ,					generator=__lowerCamelCase ,					num_inference_steps=2 ,					output_type='''numpy'''   ).images

    UpperCAmelCase__  :Tuple            =			image[0, -3:, -3:, -1]

    assert image.shape == (1, 6_4, 6_4, 3)
    UpperCAmelCase__  :Union[str, Any]            =			np.array([0.86_78, 0.82_45, 0.63_81, 0.68_30, 0.43_85, 0.55_99, 0.46_41, 0.62_01, 0.51_50]   )

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





 @unittest.skipIf(torch_device != '''cuda''' ,					'''This test requires a GPU'''   )
 def 					__SCREAMING_SNAKE_CASE				(			self       :  List[Any]   ):
    UpperCAmelCase__  :int            =			self.dummy_uncond_unet
    UpperCAmelCase__  :List[Any]            =			DDIMScheduler()
    UpperCAmelCase__  :Any            =			self.dummy_vq_model

    # put models in fp16
    UpperCAmelCase__  :List[str]            =			unet.half()
    UpperCAmelCase__  :List[Any]            =			vqvae.half()

    UpperCAmelCase__  :Union[str, Any]            =			LDMSuperResolutionPipeline(unet=__lowerCamelCase ,					vqvae=__lowerCamelCase ,					scheduler=__lowerCamelCase   )
    ldm.to(__lowerCamelCase   )
    ldm.set_progress_bar_config(disable=__lowerCamelCase   )

    UpperCAmelCase__  :Optional[Any]            =			self.dummy_image.to(__lowerCamelCase   )

    UpperCAmelCase__  :List[str]            =			ldm(__lowerCamelCase ,					num_inference_steps=2 ,					output_type='''numpy'''   ).images

    assert image.shape == (1, 6_4, 6_4, 3)




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


 def 					__SCREAMING_SNAKE_CASE				(			self       :  Optional[int]   ):
    UpperCAmelCase__  :str            =			load_image(
        '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
        '''/vq_diffusion/teddy_bear_pool.png'''   )
    UpperCAmelCase__  :List[str]            =			init_image.resize((6_4, 6_4) ,					resample=PIL_INTERPOLATION['''lanczos''']   )

    UpperCAmelCase__  :Optional[int]            =			LDMSuperResolutionPipeline.from_pretrained('''duongna/ldm-super-resolution''' ,					device_map='''auto'''   )
    ldm.set_progress_bar_config(disable=__lowerCamelCase   )

    UpperCAmelCase__  :Union[str, Any]            =			torch.manual_seed(0   )
    UpperCAmelCase__  :Any            =			ldm(image=__lowerCamelCase ,					generator=__lowerCamelCase ,					num_inference_steps=2_0 ,					output_type='''numpy'''   ).images

    UpperCAmelCase__  :List[Any]            =			image[0, -3:, -3:, -1]

    assert image.shape == (1, 2_5_6, 2_5_6, 3)
    UpperCAmelCase__  :List[Any]            =			np.array([0.76_44, 0.76_79, 0.76_42, 0.76_33, 0.76_66, 0.75_60, 0.74_25, 0.72_57, 0.69_07]   )

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







'''simple docstring'''





def 					a__    (				UpperCamelCase_	:			int = 100	):
   UpperCAmelCase__  :List[str]            =			1
   UpperCAmelCase__  :Dict            =			0
   for i in range(1,      num + 1	):
      fact *= i

   for j in str(UpperCamelCase_	):
      result += int(UpperCamelCase_	)

   return result


if __name__ == "__main__":
    print(solution(int(input('''Enter the Number: ''').strip())))



