from __future__ import annotations






def 					SCREAMING_SNAKE_CASE_			(		lowerCAmelCase_: Tuple ,	lowerCAmelCase_: Union[str, Any] ,	lowerCAmelCase_: Dict ,	lowerCAmelCase_: str     ):
      snake_case_  ,snake_case_     :			Any       =       m - 1, 0
      while i >= 0 and j < n:
            if key == mat[i][j]:
                  print(f"Key {key} found at row- {i + 1} column- {j + 1}"     )
                  return
            if key < mat[i][j]:
                  i -= 1
            else:
                  j += 1
      print(f"Key {key} not found"     )






def 					SCREAMING_SNAKE_CASE_			(		):
      snake_case_     :			List[str]       =       [[2, 5, 7], [4, 8, 1_3], [9, 1_1, 1_5], [1_2, 1_7, 2_0]]
      snake_case_     :			Optional[Any]       =       int(input("Enter the element to be searched:"     )     )
      print(lowerCAmelCase_     )
      search_in_a_sorted_matrix(lowerCAmelCase_ ,	len(lowerCAmelCase_     ) ,	len(mat[0]     ) ,	lowerCAmelCase_     )


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     main()




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



   @slow
   @unittest.skip("Model is not available."   )
   def 					UpperCAmelCase__       (				self   :   Dict   )							->     Optional[Any]:




         '''simple docstring'''




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

         snake_case_     :			Optional[int]       =       torch.tensor(
             [[1_01, 71_10, 10_05, 10_56, 20_23, 1_13_33, 1_74_13, 10_29, 1_02]]			,	device=A__			,	dtype=torch.long			,	)

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

         snake_case_     :			List[str]       =       torch.Size((1, 9, 5_02_57)   )
         self.assertEqual(output.shape			,	A__   )

         snake_case_     :			Dict       =       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=A__			,	dtype=torch.half			,	)

         for i in range(19   ):
               snake_case_  ,snake_case_     :			Dict       =       8 * i // 17, 27_92 * i  # along the diagonal
               snake_case_  ,snake_case_     :			Any       =       output[0, r, c], expected_diag[i]
               snake_case_     :			Dict       =       f"row={r} col={c} computed={computed} expected={expected}"
               self.assertAlmostEqual(A__			,	A__			,	delta=1E-4			,	msg=A__   )



