





'''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 				__UpperCAmelCase	(							unittest.TestCase    ):







		'''simple docstring'''







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

			A					=   torch.tensor(
			    [[101, 7110, 1005, 1056, 2023, 1_1333, 1_7413, 1029, 102]]   ,   device=_lowerCAmelCase   ,   dtype=torch.long   ,   )

			with torch.no_grad():
				A					=   model(_lowerCAmelCase   ).logits

			A					=   torch.Size((1, 9, 5_0257)   )
			self.assertEqual(output.shape   ,   _lowerCAmelCase   )

			A					=   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=_lowerCAmelCase   ,   dtype=torch.half   ,   )

			for i in range(19   ):
				A	,     A					=   8 * i // 17, 2792 * i  # along the diagonal
				A	,     A					=   output[0, r, c], expected_diag[i]
				A					=   F"""row={r} col={c} computed={computed} expected={expected}"""
				self.assertAlmostEqual(_lowerCAmelCase   ,   _lowerCAmelCase   ,   delta=1e-4   ,   msg=_lowerCAmelCase   )



'''simple docstring'''







def   lowerCAmelCase(  a__    :  int = 1000      ):







       '''simple docstring'''






       lowerCamelCase__				   =      0
       for i in range(a__      ):
              if i % 3 == 0 or i % 5 == 0:
                     result += i
       return result


if __name__ == "__main__":
    print(f'{solution() = }')

