code: 
  
  
  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 		snake_case_  ( self:   List[str]				):
  
  
  
  
  
  
              '''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, 1_1333, 1_7413, 1029, 102]],device=A_,dtype=torch.long,)
  
              with torch.no_grad():
                   __UpperCamelCase   = model(A_				).logits
  
              __UpperCamelCase   = torch.Size((1, 9, 5_0257)				)
              self.assertEqual(output.shape,A_				)
  
              __UpperCamelCase   = 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=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_				)
  
  
  
style_context: 
  
  
  from math import cos, sin
  
  
  
  
  
  
  def 		_A		(		_lowercase   )				->   list[list[float]]:
  
  
       """simple docstring"""
  
  
       __UpperCamelCase   = float(_lowercase   )
       return [[scaling_factor * int(x == y   ) for x in range(2   )] for y in range(2   )]
  
  
  
  
  
  
  def 		_A		(		_lowercase   )				->   list[list[float]]:
  
  
       """simple docstring"""
  
  
       __UpperCamelCase,						__UpperCamelCase   = cos(_lowercase   ), sin(_lowercase   )
       return [[c, -s], [s, c]]
  
  
  
  
  
  
  def 		_A		(		_lowercase   )				->   list[list[float]]:
  
  
       """simple docstring"""
  
  
       __UpperCamelCase,						__UpperCamelCase   = cos(_lowercase   ), sin(_lowercase   )
       __UpperCamelCase   = c * s
       return [[c * c, cs], [cs, s * s]]
  
  
  
  
  
  
  def 		_A		(		_lowercase   )				->   list[list[float]]:
  
  
       """simple docstring"""
  
  
       __UpperCamelCase,						__UpperCamelCase   = cos(_lowercase   ), sin(_lowercase   )
       __UpperCamelCase   = c * s
       return [[2 * c - 1, 2 * cs], [2 * cs, 2 * s - 1]]
  
  
  print(f"""    {scaling(5) = }""")
  print(f"""  {rotation(4_5) = }""")
  print(f"""{projection(4_5) = }""")
  
  
  print(f"""{reflection(4_5) = }""")
  
  
  