


from itertools import product






def 			UpperCamelCase (     __magic_name__					:							int   ,   __magic_name__					:							int					)       ->  list[int]:
		"""simple docstring"""




		lowercase__					      =		sides_number
		lowercase__					      =		max_face_number * dice_number
		lowercase__					      =		[0] * (max_total + 1)

		lowercase__					      =		1
		lowercase__					      =		range(__magic_name__   ,   max_face_number + 1					)
		for dice_numbers in product(__magic_name__   ,   repeat=__magic_name__					):
				lowercase__					      =		sum(__magic_name__					)
				totals_frequencies[total] += 1

		return totals_frequencies






def 			UpperCamelCase (     )       ->  float:
		"""simple docstring"""




		lowercase__					      =		total_frequency_distribution(
		    sides_number=4   ,   dice_number=9					)
		lowercase__					      =		total_frequency_distribution(
		    sides_number=6   ,   dice_number=6					)

		lowercase__					      =		0
		lowercase__					      =		9
		lowercase__					      =		4 * 9
		lowercase__					      =		6
		for peter_total in range(__magic_name__   ,   max_peter_total + 1					):
				peter_wins_count += peter_totals_frequencies[peter_total] * sum(
				    colin_totals_frequencies[min_colin_total:peter_total]					)

		lowercase__					      =		(4**9) * (6**6)
		lowercase__					      =		peter_wins_count / total_games_number

		lowercase__					      =		round(__magic_name__   ,   ndigits=7					)

		return rounded_peter_win_probability


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





from typing import List, Optional, Tuple, Union

import torch

from ...models import UNetaDModel
from ...schedulers import ScoreSdeVeScheduler
from ...utils import randn_tensor
from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput



class 							A   (	UpperCAmelCase__							):
					'''simple docstring'''






					A__      =			42
					A__      =			42

					def __init__(self   :						Union[str, Any]				, _UpperCAmelCase   :						UNetaDModel				, _UpperCAmelCase   :						ScoreSdeVeScheduler		)						->       List[str]:




							"""simple docstring"""


							super().__init__()
							self.register_modules(unet=_UpperCAmelCase				, scheduler=_UpperCAmelCase		)


					@torch.no_grad()
					def __call__(self   :						Optional[Any]				, _UpperCAmelCase   :						int = 1				, _UpperCAmelCase   :						int = 2000				, _UpperCAmelCase   :						Optional[Union[torch.Generator, List[torch.Generator]]] = None				, _UpperCAmelCase   :						Optional[str] = "pil"				, _UpperCAmelCase   :						bool = True				, **_UpperCAmelCase   :						Any				, )						->       Union[ImagePipelineOutput, Tuple]:




							"""simple docstring"""


							lowercase__					      =		self.unet.config.sample_size
							lowercase__					      =		(batch_size, 3, img_size, img_size)

							lowercase__					      =		self.unet

							lowercase__					      =		randn_tensor(_UpperCAmelCase				, generator=_UpperCAmelCase		) * self.scheduler.init_noise_sigma
							lowercase__					      =		sample.to(self.device		)

							self.scheduler.set_timesteps(_UpperCAmelCase		)
							self.scheduler.set_sigmas(_UpperCAmelCase		)

							for i, t in enumerate(self.progress_bar(self.scheduler.timesteps		)		):
									lowercase__					      =		self.scheduler.sigmas[i] * torch.ones(shape[0]				, device=self.device		)

									# correction step
									for _ in range(self.scheduler.config.correct_steps		):
											lowercase__					      =		self.unet(_UpperCAmelCase				, _UpperCAmelCase		).sample
											lowercase__					      =		self.scheduler.step_correct(_UpperCAmelCase				, _UpperCAmelCase				, generator=_UpperCAmelCase		).prev_sample

									# prediction step
									lowercase__					      =		model(_UpperCAmelCase				, _UpperCAmelCase		).sample
									lowercase__					      =		self.scheduler.step_pred(_UpperCAmelCase				, _UpperCAmelCase				, _UpperCAmelCase				, generator=_UpperCAmelCase		)

									lowercase__      ,     lowercase__					      =		output.prev_sample, output.prev_sample_mean

							lowercase__					      =		sample_mean.clamp(0				, 1		)
							lowercase__					      =		sample.cpu().permute(0				, 2				, 3				, 1		).numpy()
							if output_type == "pil":
									lowercase__					      =		self.numpy_to_pil(_UpperCAmelCase		)

							if not return_dict:
									return (sample,)

							return ImagePipelineOutput(images=_UpperCAmelCase		)

