





from __future__ import annotations

from pathlib import Path







def    UpperCAmelCase				(  _lowerCamelCase   :	Dict      , _lowerCamelCase   :	Tuple  ):





						'''simple docstring'''


						return pointa[0] * pointa[1] - pointa[1] * pointa[0]







def    UpperCAmelCase				(  _lowerCamelCase   :	str      , _lowerCamelCase   :	Optional[int]      , _lowerCamelCase   :	int      , _lowerCamelCase   :	List[Any]      , _lowerCamelCase   :	str      , _lowerCamelCase   :	Union[str, Any]  ):





						'''simple docstring'''


						SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       (xa, ya)
						SCREAMING_SNAKE_CASE__  :					Optional[int] =       (xa - xa, ya - ya)
						SCREAMING_SNAKE_CASE__  :					List[Any] =       (xa - xa, ya - ya)
						SCREAMING_SNAKE_CASE__  :					int =       -vector_product(_SCREAMING_SNAKE_CASE      , _SCREAMING_SNAKE_CASE  ) / vector_product(
						    _SCREAMING_SNAKE_CASE      , _SCREAMING_SNAKE_CASE  )
						SCREAMING_SNAKE_CASE__  :					Optional[int] =       +vector_product(_SCREAMING_SNAKE_CASE      , _SCREAMING_SNAKE_CASE  ) / vector_product(
						    _SCREAMING_SNAKE_CASE      , _SCREAMING_SNAKE_CASE  )

						return a > 0 and b > 0 and a + b < 1







def    UpperCAmelCase				(  _lowerCamelCase   :	Any = "p102_triangles.txt"  ):





						'''simple docstring'''


						SCREAMING_SNAKE_CASE__  :					str =       Path(_SCREAMING_SNAKE_CASE  ).parent.joinpath(_SCREAMING_SNAKE_CASE  ).read_text(encoding="utf-8"  )

						SCREAMING_SNAKE_CASE__  :					Dict =       []
						for line in data.strip().split("\n"  ):
												triangles.append([int(_SCREAMING_SNAKE_CASE  ) for number in line.split(","  )]  )

						SCREAMING_SNAKE_CASE__  :					List[Any] =       0
						SCREAMING_SNAKE_CASE__  :					Any =       42

						for triangle in triangles:
												ret += contains_origin(*_SCREAMING_SNAKE_CASE  )

						return ret


if __name__ == "__main__":
				print(f"{solution() = }")







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



    '''simple docstring'''


    @slow
    @unittest.skip("""Model is not available."""			)
    def 		A__      (      self			):
     UpperCAmelCase__ 						=				"""nvidia/megatron-gpt2-345m/"""
     if "MYDIR" in os.environ:
      UpperCAmelCase__ 						=				os.path.join(os.environ["""MYDIR"""]   ,			__lowercase			)
     UpperCAmelCase__ 						=				GPTaLMHeadModel.from_pretrained(__lowercase			)
     model.to(__lowercase			)
     model.half()

     UpperCAmelCase__ 						=				torch.tensor(
         [[101, 7110, 1005, 1056, 2023, 11333, 17413, 1029, 102]]   ,			device=__lowercase   ,			dtype=torch.long   ,			)

     with torch.no_grad():
      UpperCAmelCase__ 						=				model(__lowercase			).logits

     UpperCAmelCase__ 						=				torch.Size((1, 9, 50257)			)
     self.assertEqual(output.shape   ,			__lowercase			)

     UpperCAmelCase__ 						=				torch.tensor(
         [
             4.9_414,
             -0.2_920,
             -1.2_148,
             -4.0_273,
             -0.5_161,
             -5.2_109,
             -1.2_412,
             -1.8_301,
             -1.7_734,
             -4.7_148,
             -0.2_317,
             -1.0_811,
             -2.1_777,
             0.4_141,
             -3.7_969,
             -4.0_586,
             -2.5_332,
             -3.3_809,
             4.3_867,
         ]   ,			device=__lowercase   ,			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(__lowercase   ,			__lowercase   ,			delta=1e-4   ,			msg=__lowercase			)



