


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





				def __init__(				self       ,  lowercase_       ,  lowercase_=13       ,  lowercase_=7       ,  lowercase_=False       ,  lowercase_=True       ,  lowercase_=False       ,  lowercase_=False       ,  lowercase_=19       ,  lowercase_=32       ,  lowercase_=5       ,  lowercase_=4       ,  lowercase_=37       ,  lowercase_="gelu"       ,  lowercase_=0.1       ,  lowercase_=0.1       ,  lowercase_=512       ,  lowercase_=16       ,  lowercase_=2       ,  lowercase_=0.02       ,  lowercase_=3       ,  lowercase_=4       ,  lowercase_=None       ,  )  -> int:
											a__      =parent
											a__      =batch_size
											a__      =seq_length
											a__      =is_training
											a__      =use_input_mask
											a__      =use_token_type_ids
											a__      =use_labels
											a__      =vocab_size
											a__      =hidden_size
											a__      =num_hidden_layers
											a__      =num_attention_heads
											a__      =intermediate_size
											a__      =hidden_act
											a__      =hidden_dropout_prob
											a__      =attention_probs_dropout_prob
											a__      =max_position_embeddings
											a__      =type_vocab_size
											a__      =type_sequence_label_size
											a__      =initializer_range
											a__      =num_labels
											a__      =num_choices
											a__      =scope





				def 						__UpperCamelCase    (				self)  -> Union[str, Any]:
											a__      =ids_tensor([self.batch_size, self.seq_length]       ,  self.vocab_size)

											a__      =None
											if self.use_input_mask:
																		a__      =random_attention_mask([self.batch_size, self.seq_length])

											a__      =None
											a__      =None
											a__      =None
											if self.use_labels:
																		a__      =ids_tensor([self.batch_size]       ,  self.type_sequence_label_size)
																		a__      =ids_tensor([self.batch_size, self.seq_length]       ,  self.num_labels)
																		a__      =ids_tensor([self.batch_size]       ,  self.num_choices)

											a__      =self.get_config()

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





				def 						__UpperCamelCase    (				self)  -> Dict:
											a__      =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=lowercase_       ,  esmfold_config={'trunk': {'num_blocks': 2}, 'fp16_esm': False}       ,  )
											return config





				def 						__UpperCamelCase    (				self       ,  lowercase_       ,  lowercase_       ,  lowercase_       ,  lowercase_       ,  lowercase_       ,  lowercase_)  -> int:
											a__      =EsmForProteinFolding(config=lowercase_).float()
											model.to(lowercase_)
											model.eval()
											a__      =model(lowercase_       ,  attention_mask=lowercase_)
											a__      =model(lowercase_)
											a__      =model(lowercase_)

											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 						__UpperCamelCase    (				self)  -> str:
											a__      =self.prepare_config_and_inputs()
											(
											    (
											    a__
											)    ,     (
											    a__
											)    ,     (
											    a__
											)    ,     (
											    a__
											)    ,     (
											    a__
											)    ,     (
											    a__
											)    ,     
											)      =config_and_inputs
											a__      ={'input_ids': input_ids, 'attention_mask': input_mask}
											return config, inputs_dict







@require_torch
class       lowercase_					(lowercase__      ,					lowercase__      ,					unittest.TestCase   ):
				snake_case	    =False

				snake_case	    =(EsmForProteinFolding,) if is_torch_available() else ()
				snake_case	    =()
				snake_case	    ={} if is_torch_available() else {}
				snake_case	    =False





				def 						__UpperCamelCase    (				self)  -> Dict:
											a__      =EsmFoldModelTester(self)
											a__      =ConfigTester(self       ,  config_class=lowercase_       ,  hidden_size=37)





				def 						__UpperCamelCase    (				self)  -> List[Any]:
											self.config_tester.run_common_tests()





				def 						__UpperCamelCase    (				self)  -> Optional[Any]:
											a__      =self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_model(*lowercase_)





				@unittest.skip('Does not support attention outputs')
				def 						__UpperCamelCase    (				self)  -> Tuple:
											pass





				@unittest.skip
				def 						__UpperCamelCase    (				self)  -> List[Any]:
											pass





				@unittest.skip('Esm does not support embedding resizing')
				def 						__UpperCamelCase    (				self)  -> Tuple:
											pass





				@unittest.skip('Esm does not support embedding resizing')
				def 						__UpperCamelCase    (				self)  -> str:
											pass





				@unittest.skip('ESMFold does not support passing input embeds!')
				def 						__UpperCamelCase    (				self)  -> Dict:
											pass





				@unittest.skip('ESMFold does not support head pruning.')
				def 						__UpperCamelCase    (				self)  -> List[Any]:
											pass





				@unittest.skip('ESMFold does not support head pruning.')
				def 						__UpperCamelCase    (				self)  -> Any:
											pass





				@unittest.skip('ESMFold does not support head pruning.')
				def 						__UpperCamelCase    (				self)  -> Dict:
											pass





				@unittest.skip('ESMFold does not support head pruning.')
				def 						__UpperCamelCase    (				self)  -> int:
											pass





				@unittest.skip('ESMFold does not support head pruning.')
				def 						__UpperCamelCase    (				self)  -> Any:
											pass





				@unittest.skip('ESMFold does not output hidden states in the normal way.')
				def 						__UpperCamelCase    (				self)  -> Any:
											pass





				@unittest.skip('ESMfold does not output hidden states in the normal way.')
				def 						__UpperCamelCase    (				self)  -> Dict:
											pass





				@unittest.skip('ESMFold only has one output format.')
				def 						__UpperCamelCase    (				self)  -> Any:
											pass





				@unittest.skip('This test doesn\'t work for ESMFold and doesn\'t test core functionality')
				def 						__UpperCamelCase    (				self)  -> int:
											pass





				@unittest.skip('ESMFold does not support input chunking.')
				def 						__UpperCamelCase    (				self)  -> Optional[Any]:
											pass





				@unittest.skip('ESMFold doesn\'t respect you and it certainly doesn\'t respect your initialization arguments.')
				def 						__UpperCamelCase    (				self)  -> str:
											pass





				@unittest.skip('ESMFold doesn\'t support torchscript compilation.')
				def 						__UpperCamelCase    (				self)  -> Union[str, Any]:
											pass





				@unittest.skip('ESMFold doesn\'t support torchscript compilation.')
				def 						__UpperCamelCase    (				self)  -> Optional[Any]:
											pass





				@unittest.skip('ESMFold doesn\'t support torchscript compilation.')
				def 						__UpperCamelCase    (				self)  -> int:
											pass





				@unittest.skip('ESMFold doesn\'t support data parallel.')
				def 						__UpperCamelCase    (				self)  -> Union[str, Any]:
											pass





				@unittest.skip('Will be fixed soon by reducing the size of the model used for common tests.')
				def 						__UpperCamelCase    (				self)  -> List[str]:
											pass







@require_torch
class       lowercase_					(lowercase__   ):





				@slow
				def 						__UpperCamelCase    (				self)  -> Dict:
											a__      =EsmForProteinFolding.from_pretrained('facebook/esmfold_v1').float()
											model.eval()
											a__      =torch.tensor([[0, 6, 4, 13, 5, 4, 16, 12, 11, 7, 2]])
											a__      =model(lowercase_)['positions']
											a__      =torch.tensor([2.58_28, 0.79_93, -10.93_34]       ,  dtype=torch.floataa)
											self.assertTrue(torch.allclose(position_outputs[0, 0, 0, 0]       ,  lowercase_       ,  atol=1e-4))









from __future__ import annotations







def     a_   (__A      )				->						int:



					"""simple docstring"""
					__a					:						List[Any]      =					len(__A      ) // 2

					# choose the middle 3 elements
					__a					:						Any      =					lst[m - 1 : m + 2]

					# if middle element is peak
					if three[1] > three[0] and three[1] > three[2]:
										return three[1]

					# if increasing, recurse on right
					elif three[0] < three[2]:
										if len(lst[:m]      ) == 2:
															m -= 1
										return peak(lst[m:]      )

					# decreasing
					else:
										if len(lst[:m]      ) == 2:
															m += 1
										return peak(lst[:m]      )


if __name__ == "__main__":
			import doctest

			doctest.testmod()





