
from __future__ import annotations

def        lowerCamelCase_      (			UpperCAmelCase_							:				int       ):
						for r in range(1							,			UpperCAmelCase_       ):
												lowercase       :    Any											=  []
												for x in range(n - 1       ):
																		lowercase       :    Dict											=  pow(UpperCAmelCase_							,			UpperCAmelCase_							,			UpperCAmelCase_       )
																		if val in li:
																								break
																		li.append(UpperCAmelCase_       )
												else:
																		return r
						return None


if __name__ == "__main__":
				snake_case__  							=							int(input("""Enter a prime number q: """))
				snake_case__  							=							find_primitive(q)
				if a is None:
								print(F'Cannot find the primitive for the value: {a!r}')
				else:
								snake_case__  							=							int(input("""Enter private key of A: """))
								snake_case__  							=							pow(a, a_private, q)
								snake_case__  							=							int(input("""Enter private key of B: """))
								snake_case__  							=							pow(a, b_private, q)

								snake_case__  							=							pow(b_public, a_private, q)
								snake_case__  							=							pow(a_public, b_private, q)

								print("""The key value generated by A is: """, a_secret)
								print("""The key value generated by B is: """, b_secret)




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 							UpperCAmelCase	(   __lowerCamelCase					):
					a__: UNetaDModel
					a__: PNDMScheduler

					def __init__(			self      :					List[str] ,      lowerCAmelCase      :					UNetaDModel ,      lowerCAmelCase      :					PNDMScheduler					):
											super().__init__()

											lowercase       :    int											=  PNDMScheduler.from_config(scheduler.config					)

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




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

											self.scheduler.set_timesteps(lowerCAmelCase					)
											for t in self.progress_bar(self.scheduler.timesteps					):
																	lowercase       :    Dict											=  self.unet(lowerCAmelCase ,      lowerCAmelCase					).sample

																	lowercase       :    Tuple											=  self.scheduler.step(lowerCAmelCase ,      lowerCAmelCase ,      lowerCAmelCase					).prev_sample

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

											if not return_dict:
																	return (image,)

											return ImagePipelineOutput(images=lowerCAmelCase					)


