



def A    (							__UpperCamelCase       )    ->   int:
			A__	  =     [[0 for _ in range(__UpperCamelCase       )] for _ in range(m + 1       )]
			for i in range(m + 1       ):
						A__	  =     1

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

			return memo[m][m - 1]


if __name__ == "__main__":
							import sys

							if len(sys.argv) == 1:
														try:
																					SCREAMING_SNAKE_CASE__   			=   int(input('''Enter a number: ''').strip())
																					print(partition(n))
														except ValueError:
																					print('''Please enter a number.''')
							else:
														try:
																					SCREAMING_SNAKE_CASE__   			=   int(sys.argv[1])
																					print(partition(n))
														except ValueError:
																					print('''Please pass a number.''')









import argparse

import OmegaConf
import torch

from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel


def A    (							__UpperCamelCase			,						__UpperCamelCase			,						__UpperCamelCase       )    ->   int:
			A__	  =     OmegaConf.load(__UpperCamelCase       )
			A__	  =     torch.load(__UpperCamelCase			,						map_location='cpu'       )['model']
			A__	  =     list(state_dict.keys()       )

			# extract state_dict for VQVAE
			A__	  =     {}
			A__	  =     'first_stage_model.'
			for key in keys:
						if key.startswith(__UpperCamelCase       ):
									A__	  =     state_dict[key]

    # extract state_dict for UNetLDM
			A__	  =     {}
			A__	  =     'model.diffusion_model.'
			for key in keys:
						if key.startswith(__UpperCamelCase       ):
									A__	  =     state_dict[key]

			A__	  =     config.model.params.first_stage_config.params
			A__	  =     config.model.params.unet_config.params

			A__	  =     VQModel(**__UpperCamelCase       ).eval()
			vqvae.load_state_dict(__UpperCamelCase       )

			A__	  =     UNetLDMModel(**__UpperCamelCase       ).eval()
			unet.load_state_dict(__UpperCamelCase       )

			A__	  =     DDIMScheduler(
			    timesteps=config.model.params.timesteps			,						beta_schedule='scaled_linear'			,						beta_start=config.model.params.linear_start			,						beta_end=config.model.params.linear_end			,						clip_sample=__UpperCamelCase			,						)

			A__	  =     LDMPipeline(__UpperCamelCase			,						__UpperCamelCase			,						__UpperCamelCase       )
			pipeline.save_pretrained(__UpperCamelCase       )


if __name__ == "__main__":
							SCREAMING_SNAKE_CASE__   			=   argparse.ArgumentParser()
							parser.add_argument('''--checkpoint_path''', type=str, required=True)
							parser.add_argument('''--config_path''', type=str, required=True)
							parser.add_argument('''--output_path''', type=str, required=True)
							SCREAMING_SNAKE_CASE__   			=   parser.parse_args()

							convert_ldm_original(args.checkpoint_path, args.config_path, args.output_path)




