



'''simple docstring'''



def 							__UpperCAmelCase				(				UpperCamelCase__				:Any   ,				UpperCamelCase__				:Optional[int]			)		->						Tuple:
				if len(str(UpperCamelCase__			)			) == 1 or len(str(UpperCamelCase__			)			) == 1:
								return a * b

				snake_case__      :   List[str]      =    max(len(str(UpperCamelCase__			)			)   ,				len(str(UpperCamelCase__			)			)			)
				snake_case__      :   Union[str, Any]      =    ma // 2

				snake_case__  ,      snake_case__      :   Any      =    divmod(UpperCamelCase__   ,				10**ma			)
				snake_case__  ,      snake_case__      :   int      =    divmod(UpperCamelCase__   ,				10**ma			)

				snake_case__      :   Tuple      =    karatsuba(UpperCamelCase__   ,				UpperCamelCase__			)
				snake_case__      :   Any      =    karatsuba((aa + aa)   ,				(ba + ba)			)
				snake_case__      :   Union[str, Any]      =    karatsuba(UpperCamelCase__   ,				UpperCamelCase__			)

				return (z * 10 ** (2 * ma)) + ((y - z - x) * 10 ** (ma)) + (x)


def 							__UpperCAmelCase				(				)		->						int:
				print(karatsuba(1_5463   ,				2_3489			)			)


if __name__ == "__main__":
				main()











from typing import List, Optional, Tuple, Union

import torch

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



class  _a  (					lowercase__				):






							"""simple docstring"""

							def __init__(   self					:  Dict				,						a					:  str				,						a					:  Optional[Any]     )						->Any:
													super().__init__()
													self.register_modules(unet=a				,						scheduler=a     )






							@torch.no_grad()
							def __call__(   self					:  int				,						a					:  int = 1				,						a					:  Optional[Union[torch.Generator, List[torch.Generator]]] = None				,						a					:  int = 10_00				,						a					:  Optional[str] = "pil"				,						a					:  bool = True				,						)						->Union[ImagePipelineOutput, Tuple]:
													# Sample gaussian noise to begin loop
													if isinstance(self.unet.config.sample_size				,						a     ):
																			SCREAMING_SNAKE_CASE__  :					int =       (
																			    batch_size,
																			    self.unet.config.in_channels,
																			    self.unet.config.sample_size,
																			    self.unet.config.sample_size,
																			)
													else:
																			SCREAMING_SNAKE_CASE__  :					Dict =       (batch_size, self.unet.config.in_channels, *self.unet.config.sample_size)

													if self.device.type == "mps":
																			# randn does not work reproducibly on mps
																			SCREAMING_SNAKE_CASE__  :					List[str] =       randn_tensor(a				,						generator=a     )
																			SCREAMING_SNAKE_CASE__  :					Optional[int] =       image.to(self.device     )
													else:
																			SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       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
																			SCREAMING_SNAKE_CASE__  :					Optional[Any] =       self.unet(a				,						a     ).sample

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

													SCREAMING_SNAKE_CASE__  :					List[str] =       (image / 2 + 0.5).clamp(0				,						1     )
													SCREAMING_SNAKE_CASE__  :					Tuple =       image.cpu().permute(0				,						2				,						3				,						1     ).numpy()
													if output_type == "pil":
																			SCREAMING_SNAKE_CASE__  :					Dict =       self.numpy_to_pil(a     )

													if not return_dict:
																			return (image,)

													return ImagePipelineOutput(images=a     )