code: 
  
  
  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 				__SCREAMING_SNAKE_CASE   (			A__   ):
        A				:							UNetaDModel
        A				:							PNDMScheduler
  
  
        def __init__(							self							,						SCREAMING_SNAKE_CASE__							,						SCREAMING_SNAKE_CASE__		):
              super().__init__()
  
              lowercase			:   Any					   =		PNDMScheduler.from_config(scheduler.config		)
  
              self.register_modules(unet=SCREAMING_SNAKE_CASE__							,						scheduler=SCREAMING_SNAKE_CASE__		)
  
  
  
  
  
  
        @torch.no_grad()
        def __call__(							self							,						SCREAMING_SNAKE_CASE__ = 1							,						SCREAMING_SNAKE_CASE__ = 50							,						SCREAMING_SNAKE_CASE__ = None							,						SCREAMING_SNAKE_CASE__ = "pil"							,						SCREAMING_SNAKE_CASE__ = True							,						**SCREAMING_SNAKE_CASE__							,						):
              lowercase			:   List[Any]					   =		randn_tensor(
                  (batch_size, self.unet.config.in_channels, self.unet.config.sample_size, self.unet.config.sample_size)							,						generator=SCREAMING_SNAKE_CASE__							,						device=self.device							,						)
  
              self.scheduler.set_timesteps(SCREAMING_SNAKE_CASE__		)
              for t in self.progress_bar(self.scheduler.timesteps		):
                    lowercase			:   int					   =		self.unet(SCREAMING_SNAKE_CASE__							,						SCREAMING_SNAKE_CASE__		).sample
  
                    lowercase			:   Dict					   =		self.scheduler.step(SCREAMING_SNAKE_CASE__							,						SCREAMING_SNAKE_CASE__							,						SCREAMING_SNAKE_CASE__		).prev_sample
  
              lowercase			:   List[Any]					   =		(image / 2 + 0.5).clamp(0							,						1		)
              lowercase			:   Tuple					   =		image.cpu().permute(0							,						2							,						3							,						1		).numpy()
              if output_type == "pil":
                    lowercase			:   Optional[Any]					   =		self.numpy_to_pil(SCREAMING_SNAKE_CASE__		)
  
              if not return_dict:
                    return (image,)
  
              return ImagePipelineOutput(images=SCREAMING_SNAKE_CASE__		)
  
  
style_context: 
  
  
  from __future__ import annotations
  
  
  
  
  def 			__lowercase	(						_UpperCamelCase     )    ->list[int]:
  
  
  
  
  
  
  
        """simple docstring"""
  
        assert (
            isinstance(_UpperCamelCase,    _UpperCamelCase     ) and mask > 0
        ), f"""mask needs to be positive integer, your input {mask}"""
        lowercase			:   Optional[int]					   =		[]
        lowercase			:   Optional[int]					   =		mask
  
        while submask:
              all_submasks.append(_UpperCamelCase     )
              lowercase			:   Dict					   =		(submask - 1) & mask
  
        return all_submasks
  
  
  if __name__ == "__main__":
    import doctest
  
    doctest.testmod()
  
  