

from typing import List, Optional, Tuple, Union

import torch

from ...models import UNetaDModel
from ...schedulers import PNDMScheduler
from ...utils import randn_tensor
from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput



class 						a_			(				lowerCamelCase_	):



      """simple docstring"""







      __UpperCAmelCase     						= 42
      __UpperCAmelCase     						= 42
      def __init__( self	:				List[str]     ,snake_case	:				UNetaDModel     ,snake_case	:				PNDMScheduler							):
           super().__init__()

           SCREAMING_SNAKE_CASE 		=PNDMScheduler.from_config(scheduler.config							)

           self.register_modules(unet=snake_case     ,scheduler=snake_case							)


      @torch.no_grad()
      def __call__( self	:				List[Any]     ,snake_case	:				int = 1     ,snake_case	:				int = 50     ,snake_case	:				Optional[Union[torch.Generator, List[torch.Generator]]] = None     ,snake_case	:				Optional[str] = "pil"     ,snake_case	:				bool = True     ,**snake_case	:				Dict     ,):
           SCREAMING_SNAKE_CASE 		=randn_tensor(
               (batch_size, self.unet.config.in_channels, self.unet.config.sample_size, self.unet.config.sample_size)     ,generator=snake_case     ,device=self.device     ,)

           self.scheduler.set_timesteps(snake_case							)
           for t in self.progress_bar(self.scheduler.timesteps							):
                SCREAMING_SNAKE_CASE 		=self.unet(snake_case     ,snake_case							).sample

                SCREAMING_SNAKE_CASE 		=self.scheduler.step(snake_case     ,snake_case     ,snake_case							).prev_sample

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

           if not return_dict:
                return (image,)

           return ImagePipelineOutput(images=snake_case							)




import numpy as np







def      snake_case__							(  lowerCAmelCase_     ):





     """simple docstring"""







     SCREAMING_SNAKE_CASE 		=np.exp(lowerCAmelCase_     )

     # Add up the all the exponentials
     SCREAMING_SNAKE_CASE 		=np.sum(lowerCAmelCase_     )

     # Divide every exponent by the sum of all exponents
     SCREAMING_SNAKE_CASE 		=exponent_vector / sum_of_exponents

     return softmax_vector


if __name__ == "__main__":
 print(softmax((0,)))

