

'''simple docstring'''

import unittest

import numpy as np
import torch

from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel
from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device


enable_full_determinism()





class 							_snake_case (       unittest.TestCase						):
   @property
   def     __UpperCamelCase						( self			:      Dict							):
     torch.manual_seed(0							)
     SCREAMING_SNAKE_CASE:Optional[Any]						      =					UNetaDModel(
         block_out_channels=(32, 64)     ,layers_per_block=2     ,sample_size=32     ,in_channels=3     ,out_channels=3     ,down_block_types=("DownBlock2D", "AttnDownBlock2D")     ,up_block_types=("AttnUpBlock2D", "UpBlock2D")     ,)
     return model







   def     __UpperCamelCase						( self			:      int							):
     SCREAMING_SNAKE_CASE:Optional[int]						      =					self.dummy_uncond_unet
     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					KarrasVeScheduler()

     SCREAMING_SNAKE_CASE:List[Any]						      =					KarrasVePipeline(unet=SCREAMING_SNAKE_CASE__     ,scheduler=SCREAMING_SNAKE_CASE__							)
     pipe.to(SCREAMING_SNAKE_CASE__							)
     pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE__							)

     SCREAMING_SNAKE_CASE:str						      =					torch.manual_seed(0							)
     SCREAMING_SNAKE_CASE:Tuple						      =					pipe(num_inference_steps=2     ,generator=SCREAMING_SNAKE_CASE__     ,output_type="numpy"							).images

     SCREAMING_SNAKE_CASE:Any						      =					torch.manual_seed(0							)
     SCREAMING_SNAKE_CASE:str						      =					pipe(num_inference_steps=2     ,generator=SCREAMING_SNAKE_CASE__     ,output_type="numpy"     ,return_dict=SCREAMING_SNAKE_CASE__							)[0]

     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					image[0, -3:, -3:, -1]
     SCREAMING_SNAKE_CASE:int						      =					image_from_tuple[0, -3:, -3:, -1]

     assert image.shape == (1, 32, 32, 3)
     SCREAMING_SNAKE_CASE:List[Any]						      =					np.array([0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0]							)

     assert np.abs(image_slice.flatten() - expected_slice							).max() < 1e-2
     assert np.abs(image_from_tuple_slice.flatten() - expected_slice							).max() < 1e-2





@slow
@require_torch
class 							_snake_case (       unittest.TestCase						):
   def     __UpperCamelCase						( self			:      Optional[Any]							):
     SCREAMING_SNAKE_CASE:List[Any]						      =					"google/ncsnpp-celebahq-256"
     SCREAMING_SNAKE_CASE:List[str]						      =					UNetaDModel.from_pretrained(SCREAMING_SNAKE_CASE__							)
     SCREAMING_SNAKE_CASE:Optional[int]						      =					KarrasVeScheduler()

     SCREAMING_SNAKE_CASE:Optional[int]						      =					KarrasVePipeline(unet=SCREAMING_SNAKE_CASE__     ,scheduler=SCREAMING_SNAKE_CASE__							)
     pipe.to(SCREAMING_SNAKE_CASE__							)
     pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE__							)

     SCREAMING_SNAKE_CASE:Optional[Any]						      =					torch.manual_seed(0							)
     SCREAMING_SNAKE_CASE:List[str]						      =					pipe(num_inference_steps=20     ,generator=SCREAMING_SNAKE_CASE__     ,output_type="numpy"							).images

     SCREAMING_SNAKE_CASE:int						      =					image[0, -3:, -3:, -1]
     assert image.shape == (1, 256, 256, 3)
     SCREAMING_SNAKE_CASE:List[Any]						      =					np.array([0.578, 0.5_811, 0.5_924, 0.5_809, 0.587, 0.5_886, 0.5_861, 0.5_802, 0.586]							)

     assert np.abs(image_slice.flatten() - expected_slice							).max() < 1e-2









'''simple docstring'''

from math import factorial





def    A_  ( snake_case      ,       snake_case ):

  # If either of the conditions are true, the function is being asked
  # to calculate a factorial of a negative number, which is not possible
  if n < k or k < 0:
    raise ValueError("Please enter positive integers for n and k where n >= k" )
  return factorial(snake_case ) // (factorial(snake_case ) * factorial(n - k ))


if __name__ == "__main__":
    print(
        "The number of five-card hands possible from a standard",
        f'''fifty-two card deck is: {combinations(52, 5)}\n''',
    )

    print(
        "If a class of 40 students must be arranged into groups of",
        f'''4 for group projects, there are {combinations(40, 4)} ways''',
        "to arrange them.\n",
    )

    print(
        "If 10 teams are competing in a Formula One race, there",
        f'''are {combinations(10, 3)} ways that first, second and''',
        "third place can be awarded.",
    )






