



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


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

													a__:				Union[str, Any] 							=torch.tensor(
													    [[1_0_1, 7_1_1_0, 1_0_0_5, 1_0_5_6, 2_0_2_3, 1_1_3_3_3, 1_7_4_1_3, 1_0_2_9, 1_0_2]]					,				device=_UpperCAmelCase					,				dtype=torch.long					,				)

													with torch.no_grad():
																				a__:				List[str] 							=model(_UpperCAmelCase	).logits

													a__:				str 							=torch.Size((1, 9, 5_0_2_5_7)	)
													self.assertEqual(output.shape					,				_UpperCAmelCase	)

													a__:				Optional[Any] 							=torch.tensor(
													    [
													        4.9_4_1_4,
													        -0.2_9_2_0,
													        -1.2_1_4_8,
													        -4.0_2_7_3,
													        -0.5_1_6_1,
													        -5.2_1_0_9,
													        -1.2_4_1_2,
													        -1.8_3_0_1,
													        -1.7_7_3_4,
													        -4.7_1_4_8,
													        -0.2_3_1_7,
													        -1.0_8_1_1,
													        -2.1_7_7_7,
													        0.4_1_4_1,
													        -3.7_9_6_9,
													        -4.0_5_8_6,
													        -2.5_3_3_2,
													        -3.3_8_0_9,
													        4.3_8_6_7,
													    ]					,				device=_UpperCAmelCase					,				dtype=torch.half					,				)

													for i in range(1_9	):
																				a__							,	a__:				str 							=8 * i // 1_7, 2_7_9_2 * i  # along the diagonal
																				a__							,	a__:				str 							=output[0, r, c], expected_diag[i]
																				a__:				Dict 							=F"row={r} col={c} computed={computed} expected={expected}"
																				self.assertAlmostEqual(_UpperCAmelCase					,				_UpperCAmelCase					,				delta=1e-4					,				msg=_UpperCAmelCase	)









def        __lowerCAmelCase    (SCREAMING_SNAKE_CASE					)->  int:




      """simple docstring"""

      if number != int(SCREAMING_SNAKE_CASE					):
            raise ValueError('''factorial() only accepts integral values'''					)
      if number < 0:
            raise ValueError('''factorial() not defined for negative values'''					)
      snake_case_       =      1
      for i in range(1					,					number + 1					):
            value *= i
      return value






def        __lowerCAmelCase    (SCREAMING_SNAKE_CASE					)->  int:




      """simple docstring"""

      if not isinstance(SCREAMING_SNAKE_CASE					,					SCREAMING_SNAKE_CASE					):
            raise ValueError('''factorial() only accepts integral values'''					)
      if n < 0:
            raise ValueError('''factorial() not defined for negative values'''					)
      return 1 if n == 0 or n == 1 else n * factorial(n - 1					)


if __name__ == "__main__":
   import doctest

   doctest.testmod()

   UpperCAmelCase			=    int(input("""Enter a positive integer: """).strip() or 0)
   print(f'''factorial{n} is {factorial(n)}''')