


"""simple docstring"""




import os
import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device


if is_torch_available():
					import torch

					from transformers import GPTaLMHeadModel




@require_torch
@require_sentencepiece
@require_tokenizers
class  __snake_case      (unittest.TestCase     ):




							@slow
							@unittest.skip("""Model is not available."""      )
							def      __a      (    self:						Union[str, Any]      ):
										__lowerCamelCase        =			"nvidia/megatron-gpt2-345m/"
										if "MYDIR" in os.environ:
													__lowerCamelCase        =			os.path.join(os.environ["""MYDIR"""]    ,       A_      )
										__lowerCamelCase        =			GPTaLMHeadModel.from_pretrained(A_      )
										model.to(A_      )
										model.half()

										__lowerCamelCase        =			torch.tensor(
										    [[1_01, 71_10, 10_05, 10_56, 20_23, 1_13_33, 1_74_13, 10_29, 1_02]]    ,       device=A_    ,       dtype=torch.long    ,       )

										with torch.no_grad():
													__lowerCamelCase        =			model(A_      ).logits

										__lowerCamelCase        =			torch.Size((1, 9, 5_02_57)      )
										self.assertEqual(output.shape    ,       A_      )

										__lowerCamelCase        =			torch.tensor(
										    [
										        4.9_414,
										        -0.2_920,
										        -1.2_148,
										        -4.0_273,
										        -0.5_161,
										        -5.2_109,
										        -1.2_412,
										        -1.8_301,
										        -1.7_734,
										        -4.7_148,
										        -0.2_317,
										        -1.0_811,
										        -2.1_777,
										        0.4_141,
										        -3.7_969,
										        -4.0_586,
										        -2.5_332,
										        -3.3_809,
										        4.3_867,
										    ]    ,       device=A_    ,       dtype=torch.half    ,       )

										for i in range(19      ):
													__lowerCamelCase        =			8 * i // 17, 27_92 * i  # along the diagonal
													__lowerCamelCase        =			output[0, r, c], expected_diag[i]
													__lowerCamelCase        =			f'row={r} col={c} computed={computed} expected={expected}'
													self.assertAlmostEqual(A_    ,       A_    ,       delta=1E-4    ,       msg=A_      )








"""simple docstring"""




import os





def 			a_   (  ):
			__lowerCamelCase        =			os.path.dirname(os.path.realpath(lowercase__    )    )
			__lowerCamelCase        =			os.path.join(lowercase__, """triangle.txt"""    )

			with open(lowercase__    ) as in_file:
						__lowerCamelCase        =			[[int(lowercase__    ) for i in line.split()] for line in in_file]

			while len(lowercase__    ) != 1:
						__lowerCamelCase        =			triangle.pop()
						__lowerCamelCase        =			triangle[-1]
						for j in range(len(lowercase__    ) - 1    ):
									curr_row[j] += max(last_row[j], last_row[j + 1]    )
			return triangle[0][0]


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




