'''simple docstring'''




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      lowerCamelCase_     (__lowerCamelCase   ):
						'''simple docstring'''

						__UpperCamelCase:  UNetaDModel
						__UpperCamelCase:  PNDMScheduler




						def __init__(	self						:    Union[str, Any]						, A						:    UNetaDModel						, A						:    PNDMScheduler	):
													super().__init__()

													_UpperCAmelCase					:  Dict											=   PNDMScheduler.from_config(scheduler.config	)

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





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

													self.scheduler.set_timesteps(_UpperCamelCase	)
													for t in self.progress_bar(self.scheduler.timesteps	):
																				_UpperCAmelCase					:  Tuple											=   self.unet(_UpperCamelCase						, _UpperCamelCase	).sample

																				_UpperCAmelCase					:  List[str]											=   self.scheduler.step(_UpperCamelCase						, _UpperCamelCase						, _UpperCamelCase	).prev_sample

													_UpperCAmelCase					:  Tuple											=   (image / 2 + 0.5).clamp(0						, 1	)
													_UpperCAmelCase					:  Any											=   image.cpu().permute(0						, 2						, 3						, 1	).numpy()
													if output_type == "pil":
																				_UpperCAmelCase					:  Union[str, Any]											=   self.numpy_to_pil(_UpperCamelCase	)

													if not return_dict:
																				return (image,)

													return ImagePipelineOutput(images=_UpperCamelCase	)


'''simple docstring'''




def      UpperCamelCase_							( _UpperCAmelCase  :				int   )   ->   bool:


       """simple docstring"""







       _UpperCAmelCase					:  Optional[int]											=   9

       while num > 0:
              if num % 10 != digit:
                     return False
              num //= 100
              digit -= 1

       return True

def      UpperCamelCase_							( )   ->   int:


       """simple docstring"""







       _UpperCAmelCase					:  Optional[Any]											=   138_902_663

       while not is_square_form(num * num   ):
              if num % 10 == 3:
                     num -= 6  # (3 - 6) % 10 = 7
              else:
                     num -= 4  # (7 - 4) % 10 = 3

       return num * 10


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

