



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 				__A					:





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





			def        _snake_case    (self				):
						lowerCamelCase__ :      Union[str, Any]								=		ids_tensor([self.batch_size, self.seq_length]							,    self.vocab_size				)

						lowerCamelCase__ :      List[Any]								=		None
						if self.use_input_mask:
									lowerCamelCase__ :      Any								=		random_attention_mask([self.batch_size, self.seq_length]				)

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

						lowerCamelCase__ :      Any								=		self.get_config()

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





			def        _snake_case    (self				):
						lowerCamelCase__ :      Union[str, 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=lowerCamelCase__							,    esmfold_config={"""trunk""": {"""num_blocks""": 2}, """fp16_esm""": False}							,    )
						return config





			def        _snake_case    (self							,    __magic_name__							,    __magic_name__							,    __magic_name__							,    __magic_name__							,    __magic_name__							,    __magic_name__				):
						lowerCamelCase__ :      str								=		EsmForProteinFolding(config=lowerCamelCase__				).float()
						model.to(lowerCamelCase__				)
						model.eval()
						lowerCamelCase__ :      Tuple								=		model(lowerCamelCase__							,    attention_mask=lowerCamelCase__				)
						lowerCamelCase__ :      List[Any]								=		model(lowerCamelCase__				)
						lowerCamelCase__ :      str								=		model(lowerCamelCase__				)

						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        _snake_case    (self				):
						lowerCamelCase__ :      Optional[Any]								=		self.prepare_config_and_inputs()
						(
						    lowerCamelCase__    
						) :      Any								=		config_and_inputs
						lowerCamelCase__ :      int								=		{"input_ids": input_ids, "attention_mask": input_mask}
						return config, inputs_dict







@require_torch
class 				__A					( UpperCAmelCase__					, UpperCAmelCase__					, unittest.TestCase      ):
			UpperCamelCase					:str     =			False

			UpperCamelCase					:Union[str, Any]     =			(EsmForProteinFolding,) if is_torch_available() else ()
			UpperCamelCase					:Optional[Any]     =			()
			UpperCamelCase					:str     =			{} if is_torch_available() else {}
			UpperCamelCase					:str     =			False





			def        _snake_case    (self				):
						lowerCamelCase__ :      Dict								=		EsmFoldModelTester(self				)
						lowerCamelCase__ :      str								=		ConfigTester(self							,    config_class=lowerCamelCase__							,    hidden_size=37				)





			def        _snake_case    (self				):
						self.config_tester.run_common_tests()





			def        _snake_case    (self				):
						lowerCamelCase__ :      Dict								=		self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_model(*lowerCamelCase__				)





			@unittest.skip("""Does not support attention outputs"""				)
			def        _snake_case    (self				):
						pass





			@unittest.skip
			def        _snake_case    (self				):
						pass





			@unittest.skip("""Esm does not support embedding resizing"""				)
			def        _snake_case    (self				):
						pass





			@unittest.skip("""Esm does not support embedding resizing"""				)
			def        _snake_case    (self				):
						pass





			@unittest.skip("""ESMFold does not support passing input embeds!"""				)
			def        _snake_case    (self				):
						pass





			@unittest.skip("""ESMFold does not support head pruning."""				)
			def        _snake_case    (self				):
						pass





			@unittest.skip("""ESMFold does not support head pruning."""				)
			def        _snake_case    (self				):
						pass





			@unittest.skip("""ESMFold does not support head pruning."""				)
			def        _snake_case    (self				):
						pass





			@unittest.skip("""ESMFold does not support head pruning."""				)
			def        _snake_case    (self				):
						pass





			@unittest.skip("""ESMFold does not support head pruning."""				)
			def        _snake_case    (self				):
						pass





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





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





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





			@unittest.skip("""This test doesn't work for ESMFold and doesn't test core functionality"""				)
			def        _snake_case    (self				):
						pass





			@unittest.skip("""ESMFold does not support input chunking."""				)
			def        _snake_case    (self				):
						pass





			@unittest.skip("""ESMFold doesn't respect you and it certainly doesn't respect your initialization arguments."""				)
			def        _snake_case    (self				):
						pass





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





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





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





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





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







@require_torch
class 				__A					( UpperCAmelCase__      ):





			@slow
			def        _snake_case    (self				):
						lowerCamelCase__ :      List[Any]								=		EsmForProteinFolding.from_pretrained("""facebook/esmfold_v1"""				).float()
						model.eval()
						lowerCamelCase__ :      str								=		torch.tensor([[0, 6, 4, 13, 5, 4, 16, 12, 11, 7, 2]]				)
						lowerCamelCase__ :      Tuple								=		model(lowerCamelCase__				)["positions"]
						lowerCamelCase__ :      List[Any]								=		torch.tensor([2.58_28, 0.79_93, -10.9334]							,    dtype=torch.floataa				)
						self.assertTrue(torch.allclose(position_outputs[0, 0, 0, 0]							,    lowerCamelCase__							,    atol=1E-4				)				)








def      _A				(UpperCamelCase		:      int      ,			UpperCamelCase		:      int )  ->int:



			'''simple docstring'''







			while b:
						lowerCamelCase__							,lowerCamelCase__ :      int								=		b, a % b
			return a






def      _A				(UpperCamelCase		:      int      ,			UpperCamelCase		:      int )  ->int:



			'''simple docstring'''







			return a if b == 0 else euclidean_gcd_recursive(UpperCamelCase      ,			a % b )






def      _A				()  ->str:



			'''simple docstring'''







			print(f"euclidean_gcd(3, 5) = {euclidean_gcd(3      ,			5 )}" )
			print(f"euclidean_gcd(5, 3) = {euclidean_gcd(5      ,			3 )}" )
			print(f"euclidean_gcd(1, 3) = {euclidean_gcd(1      ,			3 )}" )
			print(f"euclidean_gcd(3, 6) = {euclidean_gcd(3      ,			6 )}" )
			print(f"euclidean_gcd(6, 3) = {euclidean_gcd(6      ,			3 )}" )

			print(f"euclidean_gcd_recursive(3, 5) = {euclidean_gcd_recursive(3      ,			5 )}" )
			print(f"euclidean_gcd_recursive(5, 3) = {euclidean_gcd_recursive(5      ,			3 )}" )
			print(f"euclidean_gcd_recursive(1, 3) = {euclidean_gcd_recursive(1      ,			3 )}" )
			print(f"euclidean_gcd_recursive(3, 6) = {euclidean_gcd_recursive(3      ,			6 )}" )
			print(f"euclidean_gcd_recursive(6, 3) = {euclidean_gcd_recursive(6      ,			3 )}" )


if __name__ == "__main__":
				main()



