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 						__UpperCAmelCase							(						self							:					str)		->     Tuple:


   """simple docstring"""







   _UpperCamelCase				=  "nvidia/megatron-gpt2-345m/"
   if "MYDIR" in os.environ:
     _UpperCamelCase				=  os.path.join(os.environ["MYDIR"]				,      a__)
   _UpperCamelCase				=  GPTaLMHeadModel.from_pretrained(a__)
   model.to(a__)
   model.half()

   _UpperCamelCase				=  torch.tensor(
       [[101, 7110, 1005, 1056, 2023, 11333, 17413, 1029, 102]]				,      device=a__				,      dtype=torch.long				,      )

   with torch.no_grad():
     _UpperCamelCase				=  model(a__).logits

   _UpperCamelCase				=  torch.Size((1, 9, 50257))
   self.assertEqual(output.shape				,      a__)

   _UpperCamelCase				=  torch.tensor(
       [
           4.94_14,
           -0.29_20,
           -1.21_48,
           -4.02_73,
           -0.51_61,
           -5.21_09,
           -1.24_12,
           -1.83_01,
           -1.77_34,
           -4.71_48,
           -0.23_17,
           -1.08_11,
           -2.17_77,
           0.41_41,
           -3.79_69,
           -4.05_86,
           -2.53_32,
           -3.38_09,
           4.38_67,
       ]				,      device=a__				,      dtype=torch.half				,      )

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











"""simple docstring"""


A_     :      Dict								=1_0**8





def SCREAMING_SNAKE_CASE_   (       snake_case   :					int		)->		bool:
       if n % 10 == 0:
              return False
       _lowerCamelCase    	=					str(snake_case		)
       return s == s[::-1]





def SCREAMING_SNAKE_CASE_   (       )->		int:
       _lowerCamelCase    	=					set()
       _lowerCamelCase    	=					1
       _lowerCamelCase    	=					5
       while sum_squares < LIMIT:
              _lowerCamelCase    	=					first_square + 1
              while sum_squares < LIMIT:
                     if is_palindrome(snake_case		):
                            answer.add(snake_case		)
                     last_square += 1
                     sum_squares += last_square**2
              first_square += 1
              _lowerCamelCase    	=					first_square**2 + (first_square + 1) ** 2

       return sum(snake_case		)


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






