




def   A   (   _SCREAMING_SNAKE_CASE					)			->				List[str]:
							if len(_SCREAMING_SNAKE_CASE					) > 1:
														lowerCamelCase     :   Tuple    				=      len(_SCREAMING_SNAKE_CASE					) // 2  # Finds the middle of the array
														lowerCamelCase     :   Dict    				=      arr[
														    :middle_length
														]  # Creates an array of the elements in the first half.
														lowerCamelCase     :   List[Any]    				=      arr[
														    middle_length:
														]  # Creates an array of the elements in the second half.
														lowerCamelCase     :   Optional[Any]    				=      len(_SCREAMING_SNAKE_CASE					)
														lowerCamelCase     :   Optional[Any]    				=      len(_SCREAMING_SNAKE_CASE					)
														merge(_SCREAMING_SNAKE_CASE					)  # Starts sorting the left.
														merge(_SCREAMING_SNAKE_CASE					)  # Starts sorting the right
														lowerCamelCase     :   List[str]    				=      0  # Left Counter
														lowerCamelCase     :   Optional[Any]    				=      0  # Right Counter
														lowerCamelCase     :   str    				=      0  # Position Counter
														while (
														    left_index < left_size and right_index < right_size
														):  # Runs until the lowers size of the left and right are sorted.
																					if left_array[left_index] < right_array[right_index]:
																												lowerCamelCase     :   List[Any]    				=      left_array[left_index]
																												left_index += 1
																					else:
																												lowerCamelCase     :   int    				=      right_array[right_index]
																												right_index += 1
																					index += 1
														while (
														    left_index < left_size
														):  # Adds the left over elements in the left half of the array
																					lowerCamelCase     :   Optional[Any]    				=      left_array[left_index]
																					left_index += 1
																					index += 1
														while (
														    right_index < right_size
														):  # Adds the left over elements in the right half of the array
																					lowerCamelCase     :   int    				=      right_array[right_index]
																					right_index += 1
																					index += 1
							return arr


if __name__ == "__main__":
							import doctest

							doctest.testmod()












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 					_lowercase  (					self  )  ->   List[Any]:
           lowerCamelCase     :   List[Any]    				=      "nvidia/megatron-gpt2-345m/"
           if "MYDIR" in os.environ:
                  lowerCamelCase     :   Union[str, Any]    				=      os.path.join(os.environ["MYDIR"]  ,						UpperCamelCase__  )
           lowerCamelCase     :   Any    				=      GPTaLMHeadModel.from_pretrained(UpperCamelCase__  )
           model.to(UpperCamelCase__  )
           model.half()

           lowerCamelCase     :   Dict    				=      torch.tensor(
               [[101, 7110, 1005, 1056, 2023, 1_1333, 1_7413, 1029, 102]]  ,						device=UpperCamelCase__  ,						dtype=torch.long  ,						)

           with torch.no_grad():
                  lowerCamelCase     :   Any    				=      model(UpperCamelCase__  ).logits

           lowerCamelCase     :   Union[str, Any]    				=      torch.Size((1, 9, 5_0257)  )
           self.assertEqual(output.shape  ,						UpperCamelCase__  )

           lowerCamelCase     :   List[str]    				=      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=UpperCamelCase__  ,						dtype=torch.half  ,						)

           for i in range(19  ):
                  lowerCamelCase				,   lowerCamelCase     :   Optional[int]    				=      8 * i // 17, 2792 * i  # along the diagonal
                  lowerCamelCase				,   lowerCamelCase     :   Tuple    				=      output[0, r, c], expected_diag[i]
                  lowerCamelCase     :   List[str]    				=      F'''row={r} col={c} computed={computed} expected={expected}'''
                  self.assertAlmostEqual(UpperCamelCase__  ,						UpperCamelCase__  ,						delta=1e-4  ,						msg=UpperCamelCase__  )






