



import unittest

from transformers import EsmConfig, is_torch_available
from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
		import torch

		from transformers.models.esm.modeling_esmfold import EsmForProteinFolding




class 							lowerCAmelCase__  :







					def __init__(       self      :     str			,		_A      :     Tuple			,		_A      :     Tuple=13			,		_A      :     List[Any]=7			,		_A      :     Any=False			,		_A      :     Optional[Any]=True			,		_A      :     List[Any]=False			,		_A      :     Dict=False			,		_A      :     List[Any]=19			,		_A      :     str=32			,		_A      :     List[Any]=5			,		_A      :     List[str]=4			,		_A      :     Any=37			,		_A      :     List[str]="gelu"			,		_A      :     int=0.1			,		_A      :     Dict=0.1			,		_A      :     List[Any]=512			,		_A      :     Optional[int]=16			,		_A      :     Optional[int]=2			,		_A      :     str=0.02			,		_A      :     List[Any]=3			,		_A      :     Any=4			,		_A      :     Optional[int]=None			,		):
											A__	:							List[Any]						    = parent
											A__	:							Dict						    = batch_size
											A__	:							List[str]						    = seq_length
											A__	:							List[Any]						    = is_training
											A__	:							List[str]						    = use_input_mask
											A__	:							Union[str, Any]						    = use_token_type_ids
											A__	:							Tuple						    = use_labels
											A__	:							Optional[int]						    = vocab_size
											A__	:							Union[str, Any]						    = hidden_size
											A__	:							Union[str, Any]						    = num_hidden_layers
											A__	:							int						    = num_attention_heads
											A__	:							Optional[int]						    = intermediate_size
											A__	:							List[str]						    = hidden_act
											A__	:							Optional[Any]						    = hidden_dropout_prob
											A__	:							int						    = attention_probs_dropout_prob
											A__	:							Optional[int]						    = max_position_embeddings
											A__	:							Tuple						    = type_vocab_size
											A__	:							Optional[Any]						    = type_sequence_label_size
											A__	:							int						    = initializer_range
											A__	:							str						    = num_labels
											A__	:							str						    = num_choices
											A__	:							Dict						    = scope







					def  _lowercase			(       self      :     int):
											A__	:							List[Any]						    = ids_tensor([self.batch_size, self.seq_length]			,		self.vocab_size)

											A__	:							int						    = None
											if self.use_input_mask:
																	A__	:							List[str]						    = random_attention_mask([self.batch_size, self.seq_length])

											A__	:							int						    = None
											A__	:							Optional[Any]						    = None
											A__	:							Optional[int]						    = None
											if self.use_labels:
																	A__	:							int						    = ids_tensor([self.batch_size]			,		self.type_sequence_label_size)
																	A__	:							Optional[Any]						    = ids_tensor([self.batch_size, self.seq_length]			,		self.num_labels)
																	A__	:							int						    = ids_tensor([self.batch_size]			,		self.num_choices)

											A__	:							Optional[int]						    = self.get_config()

											return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels







					def  _lowercase			(       self      :     List[Any]):
											A__	:							List[Any]						    = EsmConfig(
											    vocab_size=33			,		hidden_size=self.hidden_size			,		pad_token_id=1			,		num_hidden_layers=self.num_hidden_layers			,		num_attention_heads=self.num_attention_heads			,		intermediate_size=self.intermediate_size			,		hidden_act=self.hidden_act			,		hidden_dropout_prob=self.hidden_dropout_prob			,		attention_probs_dropout_prob=self.attention_probs_dropout_prob			,		max_position_embeddings=self.max_position_embeddings			,		type_vocab_size=self.type_vocab_size			,		initializer_range=self.initializer_range			,		is_folding_model=_A			,		esmfold_config={"trunk": {"num_blocks": 2}, "fp16_esm": False}			,		)
											return config







					def  _lowercase			(       self      :     Optional[int]			,		_A      :     Any			,		_A      :     List[str]			,		_A      :     str			,		_A      :     List[Any]			,		_A      :     Tuple			,		_A      :     Optional[Any]):
											A__	:							str						    = EsmForProteinFolding(config=_A).float()
											model.to(_A)
											model.eval()
											A__	:							Optional[Any]						    = model(_A			,		attention_mask=_A)
											A__	:							str						    = model(_A)
											A__	:							Tuple						    = model(_A)

											self.parent.assertEqual(result.positions.shape			,		(8, self.batch_size, self.seq_length, 14, 3))
											self.parent.assertEqual(result.angles.shape			,		(8, self.batch_size, self.seq_length, 7, 2))







					def  _lowercase			(       self      :     str):
											A__	:							List[str]						    = self.prepare_config_and_inputs()
											(
											    (
											    A__
											)    ,       (
											    A__
											)    ,       (
											    A__
											)    ,       (
											    A__
											)    ,       (
											    A__
											)    ,       (
											    A__
											)    ,       
											)	:							int						    = config_and_inputs
											A__	:							Union[str, Any]						    = {"input_ids": input_ids, "attention_mask": input_mask}
											return config, inputs_dict




@require_torch
class 							lowerCAmelCase__  (	UpperCamelCase					,							UpperCamelCase					,							unittest.TestCase						):
					__A     :    Optional[int]           =						False

					__A     :    Tuple           =						(EsmForProteinFolding,) if is_torch_available() else ()
					__A     :    Tuple           =						()
					__A     :    Dict           =						{} if is_torch_available() else {}
					__A     :    Tuple           =						False







					def  _lowercase			(       self      :     Optional[Any]):
											A__	:							List[str]						    = EsmFoldModelTester(self)
											A__	:							Tuple						    = ConfigTester(self			,		config_class=_A			,		hidden_size=37)







					def  _lowercase			(       self      :     Optional[int]):
											self.config_tester.run_common_tests()







					def  _lowercase			(       self      :     Dict):
											A__	:							List[str]						    = self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_model(*_A)







					@unittest.skip("Does not support attention outputs")
					def  _lowercase			(       self      :     List[str]):
											pass







					@unittest.skip
					def  _lowercase			(       self      :     List[Any]):
											pass







					@unittest.skip("Esm does not support embedding resizing")
					def  _lowercase			(       self      :     List[Any]):
											pass







					@unittest.skip("Esm does not support embedding resizing")
					def  _lowercase			(       self      :     Optional[int]):
											pass







					@unittest.skip("ESMFold does not support passing input embeds!")
					def  _lowercase			(       self      :     List[str]):
											pass







					@unittest.skip("ESMFold does not support head pruning.")
					def  _lowercase			(       self      :     Optional[int]):
											pass







					@unittest.skip("ESMFold does not support head pruning.")
					def  _lowercase			(       self      :     Optional[Any]):
											pass







					@unittest.skip("ESMFold does not support head pruning.")
					def  _lowercase			(       self      :     List[str]):
											pass







					@unittest.skip("ESMFold does not support head pruning.")
					def  _lowercase			(       self      :     Union[str, Any]):
											pass







					@unittest.skip("ESMFold does not support head pruning.")
					def  _lowercase			(       self      :     List[Any]):
											pass







					@unittest.skip("ESMFold does not output hidden states in the normal way.")
					def  _lowercase			(       self      :     str):
											pass







					@unittest.skip("ESMfold does not output hidden states in the normal way.")
					def  _lowercase			(       self      :     List[str]):
											pass







					@unittest.skip("ESMFold only has one output format.")
					def  _lowercase			(       self      :     str):
											pass







					@unittest.skip("This test doesn't work for ESMFold and doesn't test core functionality")
					def  _lowercase			(       self      :     Optional[int]):
											pass







					@unittest.skip("ESMFold does not support input chunking.")
					def  _lowercase			(       self      :     List[str]):
											pass







					@unittest.skip("ESMFold doesn't respect you and it certainly doesn't respect your initialization arguments.")
					def  _lowercase			(       self      :     Union[str, Any]):
											pass







					@unittest.skip("ESMFold doesn't support torchscript compilation.")
					def  _lowercase			(       self      :     str):
											pass







					@unittest.skip("ESMFold doesn't support torchscript compilation.")
					def  _lowercase			(       self      :     str):
											pass







					@unittest.skip("ESMFold doesn't support torchscript compilation.")
					def  _lowercase			(       self      :     Dict):
											pass







					@unittest.skip("ESMFold doesn't support data parallel.")
					def  _lowercase			(       self      :     Tuple):
											pass







					@unittest.skip("Will be fixed soon by reducing the size of the model used for common tests.")
					def  _lowercase			(       self      :     Tuple):
											pass




@require_torch
class 							lowerCAmelCase__  (	UpperCamelCase						):







					@slow
					def  _lowercase			(       self      :     int):
											A__	:							Dict						    = EsmForProteinFolding.from_pretrained("facebook/esmfold_v1").float()
											model.eval()
											A__	:							Tuple						    = torch.tensor([[0, 6, 4, 13, 5, 4, 16, 12, 11, 7, 2]])
											A__	:							str						    = model(_A)["positions"]
											A__	:							List[str]						    = torch.tensor([2.58_28, 0.79_93, -10.93_34]			,		dtype=torch.floataa)
											self.assertTrue(torch.allclose(position_outputs[0, 0, 0, 0]			,		_A			,		atol=1e-4))




from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt
def 	snake_case__       (					__lowercase       )		->		bool:







						"""simple docstring"""

						A__	:							int						    = int(number**0.5       )
						return number == sq * sq
def 	snake_case__       (					__lowercase							,     __lowercase							,     __lowercase							,     __lowercase							,     __lowercase							,     __lowercase       )		->		tuple[int, int]:







						"""simple docstring"""

						A__	:							int						    = x_num * y_den * z_den + y_num * x_den * z_den + z_num * x_den * y_den
						A__	:							int						    = x_den * y_den * z_den
						A__	:							int						    = gcd(__lowercase							,     __lowercase       )
						top //= hcf
						bottom //= hcf
						return top, bottom
def 	snake_case__       (					__lowercase = 3_5       )		->		int:







						"""simple docstring"""

						A__	:							set						    = set()
						A__	:							int
						A__	:							Fraction						    = Fraction(0       )
						A__	:							tuple[int, int]

						for x_num in range(1							,     order + 1       ):
												for x_den in range(x_num + 1							,     order + 1       ):
																		for y_num in range(1							,     order + 1       ):
																								for y_den in range(y_num + 1							,     order + 1       ):
																														# n=1
																														A__	:							Any						    = x_num * y_den + x_den * y_num
																														A__	:							List[Any]						    = x_den * y_den
																														A__	:							List[Any]						    = gcd(__lowercase							,     __lowercase       )
																														z_num //= hcf
																														z_den //= hcf
																														if 0 < z_num < z_den <= order:
																																				A__	:							List[Any]						    = add_three(
																																				    __lowercase							,     __lowercase							,     __lowercase							,     __lowercase							,     __lowercase							,     __lowercase       )
																																				unique_s.add(__lowercase       )

																														# n=2
																														A__	:							Any						    = (
																														    x_num * x_num * y_den * y_den + x_den * x_den * y_num * y_num
																														)
																														A__	:							Optional[int]						    = x_den * x_den * y_den * y_den
																														if is_sq(__lowercase       ) and is_sq(__lowercase       ):
																																				A__	:							Union[str, Any]						    = int(sqrt(__lowercase       )       )
																																				A__	:							int						    = int(sqrt(__lowercase       )       )
																																				A__	:							Any						    = gcd(__lowercase							,     __lowercase       )
																																				z_num //= hcf
																																				z_den //= hcf
																																				if 0 < z_num < z_den <= order:
																																										A__	:							List[Any]						    = add_three(
																																										    __lowercase							,     __lowercase							,     __lowercase							,     __lowercase							,     __lowercase							,     __lowercase       )
																																										unique_s.add(__lowercase       )

                    # n=-1
																														A__	:							Tuple						    = x_num * y_num
																														A__	:							int						    = x_den * y_num + x_num * y_den
																														A__	:							List[str]						    = gcd(__lowercase							,     __lowercase       )
																														z_num //= hcf
																														z_den //= hcf
																														if 0 < z_num < z_den <= order:
																																				A__	:							str						    = add_three(
																																				    __lowercase							,     __lowercase							,     __lowercase							,     __lowercase							,     __lowercase							,     __lowercase       )
																																				unique_s.add(__lowercase       )

																														# n=2
																														A__	:							Any						    = x_num * x_num * y_num * y_num
																														A__	:							List[str]						    = (
																														    x_den * x_den * y_num * y_num + x_num * x_num * y_den * y_den
																														)
																														if is_sq(__lowercase       ) and is_sq(__lowercase       ):
																																				A__	:							Optional[int]						    = int(sqrt(__lowercase       )       )
																																				A__	:							List[Any]						    = int(sqrt(__lowercase       )       )
																																				A__	:							Union[str, Any]						    = gcd(__lowercase							,     __lowercase       )
																																				z_num //= hcf
																																				z_den //= hcf
																																				if 0 < z_num < z_den <= order:
																																										A__	:							Optional[Any]						    = add_three(
																																										    __lowercase							,     __lowercase							,     __lowercase							,     __lowercase							,     __lowercase							,     __lowercase       )
																																										unique_s.add(__lowercase       )

						for num, den in unique_s:
												total += Fraction(__lowercase							,     __lowercase       )

						return total.denominator + total.numerator


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