




"""simple docstring"""





import tempfile
import unittest

import numpy as np
import torch

from diffusers import DiffusionPipeline
from diffusers.models.attention_processor import Attention, AttnAddedKVProcessor

class    __lowercase							(      unittest.TestCase						):


				'''simple docstring'''


				def    _lowerCamelCase       ( self :  Tuple   ,SCREAMING_SNAKE_CASE_ :  bool = False   ):
										snake_case__							:       Union[str, Any]				      =       1_0

										if only_cross_attention:
																snake_case__							:       Optional[Any]				      =       1_2
										else:
																# when only cross attention is not set, the cross attention dim must be the same as the query dim
																snake_case__							:       Union[str, Any]				      =       query_dim

										return {
										    "query_dim": query_dim,
										    "cross_attention_dim": cross_attention_dim,
										    "heads": 2,
										    "dim_head": 4,
										    "added_kv_proj_dim": 6,
										    "norm_num_groups": 1,
										    "only_cross_attention": only_cross_attention,
										    "processor": AttnAddedKVProcessor(),
										}

				def    _lowerCamelCase       ( self :  List[str]   ,SCREAMING_SNAKE_CASE_ :  Tuple   ,SCREAMING_SNAKE_CASE_ :  Union[str, Any]   ):
										snake_case__							:       Optional[int]				      =       2

										snake_case__							:       List[str]				      =       torch.rand(lowercase_   ,lowercase_   ,3   ,2   )
										snake_case__							:       Dict				      =       torch.rand(lowercase_   ,4   ,lowercase_   )
										snake_case__							:       str				      =       None

										return {
										    "hidden_states": hidden_states,
										    "encoder_hidden_states": encoder_hidden_states,
										    "attention_mask": attention_mask,
										}





				def    _lowerCamelCase       ( self :  Dict   ):
										# self and cross attention

										torch.manual_seed(0   )

										snake_case__							:       Any				      =       self.get_constructor_arguments(only_cross_attention=lowercase_   )
										snake_case__							:       List[str]				      =       Attention(**lowercase_   )

										self.assertTrue(attn.to_k is not None   )
										self.assertTrue(attn.to_v is not None   )

										snake_case__							:       List[Any]				      =       self.get_forward_arguments(
										    query_dim=constructor_args['''query_dim''']   ,added_kv_proj_dim=constructor_args['''added_kv_proj_dim''']   )

										snake_case__							:       Dict				      =       attn(**lowercase_   )

										# only self attention

										torch.manual_seed(0   )

										snake_case__							:       Tuple				      =       self.get_constructor_arguments(only_cross_attention=lowercase_   )
										snake_case__							:       Union[str, Any]				      =       Attention(**lowercase_   )

										self.assertTrue(attn.to_k is None   )
										self.assertTrue(attn.to_v is None   )

										snake_case__							:       Dict				      =       self.get_forward_arguments(
										    query_dim=constructor_args['''query_dim''']   ,added_kv_proj_dim=constructor_args['''added_kv_proj_dim''']   )

										snake_case__							:       Any				      =       attn(**lowercase_   )

										self.assertTrue((only_cross_attn_out != self_and_cross_attn_out).all()   )







class    __lowercase							(      unittest.TestCase						):


				'''simple docstring'''


				def    _lowerCamelCase       ( self :  str   ):
										snake_case__							:       List[Any]				      =       DiffusionPipeline.from_pretrained('''hf-internal-testing/tiny-stable-diffusion-pipe'''   ,safety_checker=lowercase_   )

										snake_case__							:       List[Any]				      =       pipe(
										    '''foo'''   ,num_inference_steps=2   ,generator=torch.Generator('''cpu'''   ).manual_seed(0   )   ,output_type='''np'''   ,).images

										# the initial conversion succeeds
										snake_case__							:       List[str]				      =       DiffusionPipeline.from_pretrained(
										    '''hf-internal-testing/tiny-stable-diffusion-pipe'''   ,device_map='''sequential'''   ,safety_checker=lowercase_   )

										snake_case__							:       Optional[Any]				      =       pipe(
										    '''foo'''   ,num_inference_steps=2   ,generator=torch.Generator('''cpu'''   ).manual_seed(0   )   ,output_type='''np'''   ,).images

										with tempfile.TemporaryDirectory() as tmpdir:
																# save the converted model
																pipe.save_pretrained(lowercase_   )

																# can also load the converted weights
																snake_case__							:       Optional[int]				      =       DiffusionPipeline.from_pretrained(lowercase_   ,device_map='''sequential'''   ,safety_checker=lowercase_   )

										snake_case__							:       Union[str, Any]				      =       pipe(
										    '''foo'''   ,num_inference_steps=2   ,generator=torch.Generator('''cpu'''   ).manual_seed(0   )   ,output_type='''np'''   ,).images

										self.assertTrue(np.allclose(lowercase_   ,lowercase_   ,atol=1E-5   )   )
										self.assertTrue(np.allclose(lowercase_   ,lowercase_   ,atol=1E-5   )   )





'''simple docstring'''

def  UpperCamelCase(	UpperCAmelCase_ = 1_00      ):
 UpperCAmelCase			:      Optional[Any]		   =					[[0 for _ in range(UpperCAmelCase_      )] for _ in range(m + 1      )]
 for i in range(m + 1      ):
  UpperCAmelCase			:      Optional[int]		   =					1

 for n in range(m + 1      ):
  for k in range(1    ,			UpperCAmelCase_      ):
   memo[n][k] += memo[n][k - 1]
   if n > k:
    memo[n][k] += memo[n - k - 1][k]

 return memo[m][m - 1] - 1


if __name__ == "__main__":
 print(solution(int(input("Enter a number: ").strip())))




