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




				@slow
				@unittest.skip('''Model is not available.'''   )
				def 						__snake_case				(				self						:					Tuple   ):
										snake_case							:  List[Any]			=     '''nvidia/megatron-gpt2-345m/'''
										if "MYDIR" in os.environ:
																snake_case							:  List[str]			=     os.path.join(os.environ['''MYDIR'''],     SCREAMING_SNAKE_CASE_   )
										snake_case							:  Optional[int]			=     GPTaLMHeadModel.from_pretrained(SCREAMING_SNAKE_CASE_   )
										model.to(SCREAMING_SNAKE_CASE_   )
										model.half()

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

										with torch.no_grad():
																snake_case							:  Union[str, Any]			=     model(SCREAMING_SNAKE_CASE_   ).logits

										snake_case							:  Tuple			=     torch.Size((1, 9, 5_02_57)   )
										self.assertEqual(output.shape,     SCREAMING_SNAKE_CASE_   )

										snake_case							:  int			=     torch.tensor(
										    [
										        4.9414,
										        -0.2920,
										        -1.2148,
										        -4.0273,
										        -0.5161,
										        -5.2109,
										        -1.2412,
										        -1.8301,
										        -1.7734,
										        -4.7148,
										        -0.2317,
										        -1.0811,
										        -2.1777,
										        0.4141,
										        -3.7969,
										        -4.0586,
										        -2.5332,
										        -3.3809,
										        4.3867,
										    ],     device=SCREAMING_SNAKE_CASE_,     dtype=torch.half,     )

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


"""simple docstring"""






def     a_		(   lowerCamelCase			):
				if num < 0:
								return -1
				return 1 if num else 0



def     a_		(   ):
				assert signum(5			) == 1
				assert signum(-5			) == -1
				assert signum(0			) == 0


if __name__ == "__main__":
						print(signum(12))
						print(signum(-12))
						print(signum(0))



