'''simple docstring'''




import unittest

import numpy as np
import torch

from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel
from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device


enable_full_determinism()

class 	lowerCamelCase_	(unittest.TestCase    ):
      '''simple docstring'''

      @property
      def      _A	(       self						:				List[Any]       ):
             torch.manual_seed(0       )
             _UpperCAmelCase     :  Optional[int]							      =    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      _A	(       self						:				Optional[Any]       ):
             _UpperCAmelCase     :  str							      =    self.dummy_uncond_unet
             _UpperCAmelCase     :  List[str]							      =    PNDMScheduler()

             _UpperCAmelCase     :  Optional[int]							      =    PNDMPipeline(unet=A						,					scheduler=A       )
             pndm.to(A       )
             pndm.set_progress_bar_config(disable=A       )

             _UpperCAmelCase     :  Any							      =    torch.manual_seed(0       )
             _UpperCAmelCase     :  str							      =    pndm(generator=A						,					num_inference_steps=20						,					output_type="numpy"       ).images

             _UpperCAmelCase     :  List[str]							      =    torch.manual_seed(0       )
             _UpperCAmelCase     :  Any							      =    pndm(generator=A						,					num_inference_steps=20						,					output_type="numpy"						,					return_dict=A       )[0]

             _UpperCAmelCase     :  Dict							      =    image[0, -3:, -3:, -1]
             _UpperCAmelCase     :  int							      =    image_from_tuple[0, -3:, -3:, -1]

             assert image.shape == (1, 32, 32, 3)
             _UpperCAmelCase     :  List[str]							      =    np.array([1.0, 1.0, 0.0, 1.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 	lowerCamelCase_	(unittest.TestCase    ):
      '''simple docstring'''

      def      _A	(       self						:				Union[str, Any]       ):
             _UpperCAmelCase     :  List[Any]							      =    "google/ddpm-cifar10-32"

             _UpperCAmelCase     :  int							      =    UNetaDModel.from_pretrained(A       )
             _UpperCAmelCase     :  Dict							      =    PNDMScheduler()

             _UpperCAmelCase     :  str							      =    PNDMPipeline(unet=A						,					scheduler=A       )
             pndm.to(A       )
             pndm.set_progress_bar_config(disable=A       )
             _UpperCAmelCase     :  str							      =    torch.manual_seed(0       )
             _UpperCAmelCase     :  Optional[int]							      =    pndm(generator=A						,					output_type="numpy"       ).images

             _UpperCAmelCase     :  str							      =    image[0, -3:, -3:, -1]

             assert image.shape == (1, 32, 32, 3)
             _UpperCAmelCase     :  str							      =    np.array([0.1_564, 0.14_645, 0.1_406, 0.14_715, 0.12_425, 0.14_045, 0.13_115, 0.12_175, 0.125]       )

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


'''simple docstring'''




def 	UpperCamelCase_							(					_UpperCAmelCase  :      int			,	_UpperCAmelCase  :      int    )    ->    int:


       """simple docstring"""







       _UpperCAmelCase     :  List[str]							      =    1  # To kept the Calculated Value
       # Since C(n, k) = C(n, n-k)
       if k > (n - k):
              _UpperCAmelCase     :  Any							      =    n - k
       # Calculate C(n,k)
       for i in range(_UpperCAmelCase    ):
              result *= n - i
              result //= i + 1
       return result

def 	UpperCamelCase_							(					_UpperCAmelCase  :      int    )    ->    int:


       """simple docstring"""







       return binomial_coefficient(2 * node_count			,	_UpperCAmelCase    ) // (node_count + 1)

def 	UpperCamelCase_							(					_UpperCAmelCase  :      int    )    ->    int:


       """simple docstring"""







       if n < 0:
              raise ValueError("factorial() not defined for negative values"    )
       _UpperCAmelCase     :  List[str]							      =    1
       for i in range(1			,	n + 1    ):
              result *= i
       return result

def 	UpperCamelCase_							(					_UpperCAmelCase  :      int    )    ->    int:


       """simple docstring"""







       return catalan_number(_UpperCAmelCase    ) * factorial(_UpperCAmelCase    )


if __name__ == "__main__":
  __SCREAMING_SNAKE_CASE       :     Dict     =  int(input("""Enter the number of nodes: """).strip() or 0)
  if node_count <= 0:
    raise ValueError("""We need some nodes to work with.""")
  print(
      F'Given {node_count} nodes, there are {binary_tree_count(node_count)} '
      F'binary trees and {catalan_number(node_count)} binary search trees.'
  )

