


'''simple docstring'''

from typing import List, Optional, Tuple, Union

import torch

from ...utils import randn_tensor
from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput







class  UpperCAmelCase (       SCREAMING_SNAKE_CASE__):

 def __init__( self :	Dict,					a_ :	Optional[Any],					a_ :	Any					):





    """simple docstring"""



    super().__init__()
    self.register_modules(unet=a_,					scheduler=a_					)

 @torch.no_grad()
 def __call__( self :	List[Any],					a_ :	int = 1,					a_ :	Optional[Union[torch.Generator, List[torch.Generator]]] = None,					a_ :	int = 1000,					a_ :	Optional[str] = "pil",					a_ :	bool = True,					):





    """simple docstring"""



    if isinstance(self.unet.config.sample_size,					a_					):
       UpperCamelCase__ 						=						(
           batch_size,
           self.unet.config.in_channels,
           self.unet.config.sample_size,
           self.unet.config.sample_size,
       )
    else:
       UpperCamelCase__ 						=						(batch_size, self.unet.config.in_channels, *self.unet.config.sample_size)

    if self.device.type == "mps":
       # randn does not work reproducibly on mps
       UpperCamelCase__ 						=						randn_tensor(a_,					generator=a_					)
       UpperCamelCase__ 						=						image.to(self.device					)
    else:
       UpperCamelCase__ 						=						randn_tensor(a_,					generator=a_,					device=self.device					)

    # set step values
    self.scheduler.set_timesteps(a_					)

    for t in self.progress_bar(self.scheduler.timesteps					):
       # 1. predict noise model_output
       UpperCamelCase__ 						=						self.unet(a_,					a_					).sample

       # 2. compute previous image: x_t -> x_t-1
       UpperCamelCase__ 						=						self.scheduler.step(a_,					a_,					a_,					generator=a_					).prev_sample

    UpperCamelCase__ 						=						(image / 2 + 0.5).clamp(0,					1					)
    UpperCamelCase__ 						=						image.cpu().permute(0,					2,					3,					1					).numpy()
    if output_type == "pil":
       UpperCamelCase__ 						=						self.numpy_to_pil(a_					)

    if not return_dict:
       return (image,)

    return ImagePipelineOutput(images=a_					)



'''simple docstring'''

def        SCREAMING_SNAKE_CASE__(		_UpperCamelCase      :				int = 10_00   )		->					int:





   '''simple docstring'''







   return sum(i for i in range(_UpperCamelCase   ) if i % 3 == 0 or i % 5 == 0   )


if __name__ == "__main__":
       print(F"""{solution() = }""")