"""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       a_      (     unittest.TestCase			):




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

							lowerCAmelCase__        =   PNDMPipeline(unet=snake_case__  ,						scheduler=snake_case__     )
							pndm.to(snake_case__     )
							pndm.set_progress_bar_config(disable=snake_case__     )

							lowerCAmelCase__        =   torch.manual_seed(0     )
							lowerCAmelCase__        =   pndm(generator=snake_case__  ,						num_inference_steps=20  ,						output_type="""numpy"""     ).images

							lowerCAmelCase__        =   torch.manual_seed(0     )
							lowerCAmelCase__        =   pndm(generator=snake_case__  ,						num_inference_steps=20  ,						output_type="""numpy"""  ,						return_dict=snake_case__     )[0]

							lowerCAmelCase__        =   image[0, -3:, -3:, -1]
							lowerCAmelCase__        =   image_from_tuple[0, -3:, -3:, -1]

							assert image.shape == (1, 32, 32, 3)
							lowerCAmelCase__        =   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       a_      (     unittest.TestCase			):




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Union[str, Any]     ):
							lowerCAmelCase__        =   """google/ddpm-cifar10-32"""

							lowerCAmelCase__        =   UNetaDModel.from_pretrained(snake_case__     )
							lowerCAmelCase__        =   PNDMScheduler()

							lowerCAmelCase__        =   PNDMPipeline(unet=snake_case__  ,						scheduler=snake_case__     )
							pndm.to(snake_case__     )
							pndm.set_progress_bar_config(disable=snake_case__     )
							lowerCAmelCase__        =   torch.manual_seed(0     )
							lowerCAmelCase__        =   pndm(generator=snake_case__  ,						output_type="""numpy"""     ).images

							lowerCAmelCase__        =   image[0, -3:, -3:, -1]

							assert image.shape == (1, 32, 32, 3)
							lowerCAmelCase__        =   np.array([0.1564, 0.1_4645, 0.1406, 0.1_4715, 0.1_2425, 0.1_4045, 0.1_3115, 0.1_2175, 0.125]     )

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





"""simple docstring"""




import os







def 							_UpperCAmelCase		(       ):





		"""simple docstring"""




		lowerCAmelCase__        =   os.path.dirname(os.path.realpath(lowerCamelCase__     )     )
		lowerCAmelCase__        =   os.path.join(lowerCamelCase__			,  """triangle.txt"""     )

		with open(lowerCamelCase__     ) as f:
				lowerCAmelCase__        =   f.readlines()

		lowerCAmelCase__        =   []
		for line in triangle:
				lowerCAmelCase__        =   []
				for number in line.strip().split(""" """     ):
						numbers_from_line.append(int(lowerCamelCase__     )     )
				a.append(lowerCamelCase__     )

		for i in range(1			,  len(lowerCamelCase__     )     ):
				for j in range(len(a[i]     )     ):
						lowerCAmelCase__        =   a[i - 1][j] if j != len(a[i - 1]     ) else 0
						lowerCAmelCase__        =   a[i - 1][j - 1] if j > 0 else 0
						a[i][j] += max(lowerCamelCase__			,  lowerCamelCase__     )
		return max(a[-1]     )


if __name__ == "__main__":
			print(solution())




