
    +h6                     n    S SK JrJrJrJr  S SKrSSKJr  SSKJ	r	  SSK
Jr  SSKJrJr   " S	 S
\5      rg)    )ListOptionalTupleUnionN   )UNet2DModel)PNDMScheduler)randn_tensor   )DiffusionPipelineImagePipelineOutputc                      ^  \ rS rSr% Sr\\S'   \\S'   S\S\4U 4S jjr\	R                  " 5            SS\S\S\\\	R                  \\	R                     4      S	\\   S
\S\\\4   4S jj5       rSrU =r$ )PNDMPipeline   a  
Pipeline for unconditional image generation.

This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).

Parameters:
    unet ([`UNet2DModel`]):
        A `UNet2DModel` to denoise the encoded image latents.
    scheduler ([`PNDMScheduler`]):
        A `PNDMScheduler` to be used in combination with `unet` to denoise the encoded image.
unet	schedulerc                    > [         TU ]  5         [        R                  " UR                  5      nU R                  XS9  g )N)r   r   )super__init__r	   from_configconfigregister_modules)selfr   r   	__class__s      k/home/james-whalen/.local/lib/python3.13/site-packages/diffusers/pipelines/deprecated/pndm/pipeline_pndm.pyr   PNDMPipeline.__init__+   s5    !--i.>.>?	4=    
batch_sizenum_inference_steps	generatoroutput_typereturn_dictreturnc                    [        XR                  R                  R                  U R                  R                  R                  U R                  R                  R                  4UU R
                  S9nU R                  R                  U5        U R                  U R                  R                  5       HD  nU R                  Xx5      R                  n	U R                  R                  XU5      R                  nMF     US-  S-   R                  SS5      nUR                  5       R                  SSSS5      R!                  5       nUS:X  a  U R#                  U5      nU(       d  U4$ [%        US9$ )	ap  
The call function to the pipeline for generation.

Args:
    batch_size (`int`, `optional`, defaults to 1):
        The number of images to generate.
    num_inference_steps (`int`, `optional`, defaults to 50):
        The number of denoising steps. More denoising steps usually lead to a higher quality image at the
        expense of slower inference.
    generator (`torch.Generator`, `optional`):
        A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make
        generation deterministic.
    output_type (`str`, `optional`, defaults to `"pil"`):
        The output format of the generated image. Choose between `PIL.Image` or `np.array`.
    return_dict (`bool`, *optional*, defaults to `True`):
        Whether or not to return a [`ImagePipelineOutput`] instead of a plain tuple.

Example:

```py
>>> from diffusers import PNDMPipeline

>>> # load model and scheduler
>>> pndm = PNDMPipeline.from_pretrained("google/ddpm-cifar10-32")

>>> # run pipeline in inference (sample random noise and denoise)
>>> image = pndm().images[0]

>>> # save image
>>> image.save("pndm_generated_image.png")
```

Returns:
    [`~pipelines.ImagePipelineOutput`] or `tuple`:
        If `return_dict` is `True`, [`~pipelines.ImagePipelineOutput`] is returned, otherwise a `tuple` is
        returned where the first element is a list with the generated images.
)r    device   g      ?r      r   pil)images)r
   r   r   in_channelssample_sizer%   r   set_timestepsprogress_bar	timestepssamplestepprev_sampleclampcpupermutenumpynumpy_to_pilr   )
r   r   r   r    r!   r"   kwargsimagetmodel_outputs
             r   __call__PNDMPipeline.__call__2   s(   f ))55tyy7G7G7S7SUYU^U^UeUeUqUqr;;
 	$$%89""4>>#;#;<A99U.55LNN''?KKE =
 S''1-		##Aq!Q/557%%%e,E8O"%00r    )r'   2   Nr(   T)__name__
__module____qualname____firstlineno____doc__r   __annotations__r	   r   torchno_gradintr   r   	Generatorr   strboolr   r   r;   __static_attributes____classcell__)r   s   @r   r   r      s     >[ >] > ]]_ #%MQ%* F1F1 !F1 E%//43H"HIJ	F1
 c]F1 F1 
"E)	*F1 F1r   r   )typingr   r   r   r   rE   modelsr   
schedulersr	   utils.torch_utilsr
   pipeline_utilsr   r   r   r=   r   r   <module>rR      s+     0 /  " ( . D_1$ _1r   