



'''simple docstring'''



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 :   Tuple					,     lowerCAmelCase__ :   List[str]					,     lowerCAmelCase__ :   Dict=13					,     lowerCAmelCase__ :   str=7					,     lowerCAmelCase__ :   List[Any]=False					,     lowerCAmelCase__ :   Optional[Any]=True					,     lowerCAmelCase__ :   Optional[int]=False					,     lowerCAmelCase__ :   int=False					,     lowerCAmelCase__ :   List[str]=19					,     lowerCAmelCase__ :   Optional[Any]=32					,     lowerCAmelCase__ :   List[str]=5					,     lowerCAmelCase__ :   List[Any]=4					,     lowerCAmelCase__ :   Optional[int]=37					,     lowerCAmelCase__ :   Dict="gelu"					,     lowerCAmelCase__ :   List[str]=0.1					,     lowerCAmelCase__ :   str=0.1					,     lowerCAmelCase__ :   int=5_12					,     lowerCAmelCase__ :   List[Any]=16					,     lowerCAmelCase__ :   Union[str, Any]=2					,     lowerCAmelCase__ :   List[str]=0.02					,     lowerCAmelCase__ :   Optional[Any]=3					,     lowerCAmelCase__ :   str=4					,     lowerCAmelCase__ :   Optional[Any]=None					,     ):

													"""simple docstring"""
													SCREAMING_SNAKE_CASE       :   str         =      parent
													SCREAMING_SNAKE_CASE       :   List[Any]         =      batch_size
													SCREAMING_SNAKE_CASE       :   Any         =      seq_length
													SCREAMING_SNAKE_CASE       :   Optional[Any]         =      is_training
													SCREAMING_SNAKE_CASE       :   Optional[Any]         =      use_input_mask
													SCREAMING_SNAKE_CASE       :   Optional[Any]         =      use_token_type_ids
													SCREAMING_SNAKE_CASE       :   List[str]         =      use_labels
													SCREAMING_SNAKE_CASE       :   str         =      vocab_size
													SCREAMING_SNAKE_CASE       :   Optional[int]         =      hidden_size
													SCREAMING_SNAKE_CASE       :   str         =      num_hidden_layers
													SCREAMING_SNAKE_CASE       :   Any         =      num_attention_heads
													SCREAMING_SNAKE_CASE       :   int         =      intermediate_size
													SCREAMING_SNAKE_CASE       :   Union[str, Any]         =      hidden_act
													SCREAMING_SNAKE_CASE       :   List[str]         =      hidden_dropout_prob
													SCREAMING_SNAKE_CASE       :   Any         =      attention_probs_dropout_prob
													SCREAMING_SNAKE_CASE       :   List[Any]         =      max_position_embeddings
													SCREAMING_SNAKE_CASE       :   Optional[int]         =      type_vocab_size
													SCREAMING_SNAKE_CASE       :   Optional[Any]         =      type_sequence_label_size
													SCREAMING_SNAKE_CASE       :   Tuple         =      initializer_range
													SCREAMING_SNAKE_CASE       :   Optional[int]         =      num_labels
													SCREAMING_SNAKE_CASE       :   Optional[Any]         =      num_choices
													SCREAMING_SNAKE_CASE       :   List[Any]         =      scope







						def        __lowercase     (	self :   Any					):

													"""simple docstring"""
													SCREAMING_SNAKE_CASE       :   Any         =      ids_tensor([self.batch_size, self.seq_length]					,     self.vocab_size					)

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

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

													SCREAMING_SNAKE_CASE       :   Any         =      self.get_config()

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







						def        __lowercase     (	self :   str					):

													"""simple docstring"""
													SCREAMING_SNAKE_CASE       :   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=lowerCAmelCase__					,     esmfold_config={'''trunk''': {'''num_blocks''': 2}, '''fp16_esm''': False}					,     )
													return config







						def        __lowercase     (	self :   List[Any]					,     lowerCAmelCase__ :   Any					,     lowerCAmelCase__ :   List[str]					,     lowerCAmelCase__ :   Optional[int]					,     lowerCAmelCase__ :   Optional[int]					,     lowerCAmelCase__ :   int					,     lowerCAmelCase__ :   Any					):

													"""simple docstring"""
													SCREAMING_SNAKE_CASE       :   Tuple         =      EsmForProteinFolding(config=lowerCAmelCase__					).float()
													model.to(lowerCAmelCase__					)
													model.eval()
													SCREAMING_SNAKE_CASE       :   List[str]         =      model(lowerCAmelCase__					,     attention_mask=lowerCAmelCase__					)
													SCREAMING_SNAKE_CASE       :   Any         =      model(lowerCAmelCase__					)
													SCREAMING_SNAKE_CASE       :   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        __lowercase     (	self :   str					):

													"""simple docstring"""
													SCREAMING_SNAKE_CASE       :   Any         =      self.prepare_config_and_inputs()
													(
													    (
													    SCREAMING_SNAKE_CASE
													)       ,(
													    SCREAMING_SNAKE_CASE
													)       ,(
													    SCREAMING_SNAKE_CASE
													)       ,(
													    SCREAMING_SNAKE_CASE
													)       ,(
													    SCREAMING_SNAKE_CASE
													)       ,(
													    SCREAMING_SNAKE_CASE
													)       ,
													)       :   Optional[int]         =      config_and_inputs
													SCREAMING_SNAKE_CASE       :   str         =      {'''input_ids''': input_ids, '''attention_mask''': input_mask}
													return config, inputs_dict


@require_torch
class 						lowerCamelCase_				(       snake_case_     ,					snake_case_     ,					unittest.TestCase      ):
						_lowerCAmelCase  : str						  =					False

						_lowerCAmelCase  : int						  =					(EsmForProteinFolding,) if is_torch_available() else ()
						_lowerCAmelCase  : Optional[int]						  =					()
						_lowerCAmelCase  : Tuple						  =					{} if is_torch_available() else {}
						_lowerCAmelCase  : int						  =					False







						def        __lowercase     (	self :   Tuple					):

													"""simple docstring"""
													SCREAMING_SNAKE_CASE       :   Any         =      EsmFoldModelTester(self					)
													SCREAMING_SNAKE_CASE       :   Union[str, Any]         =      ConfigTester(self					,     config_class=lowerCAmelCase__					,     hidden_size=37					)







						def        __lowercase     (	self :   Optional[Any]					):

													"""simple docstring"""
													self.config_tester.run_common_tests()







						def        __lowercase     (	self :   str					):

													"""simple docstring"""
													SCREAMING_SNAKE_CASE       :   Optional[int]         =      self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_model(*lowerCAmelCase__					)







						@unittest.skip('''Does not support attention outputs'''					)
						def        __lowercase     (	self :   Any					):

													"""simple docstring"""
													pass







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

													"""simple docstring"""
													pass







						@unittest.skip('''Esm does not support embedding resizing'''					)
						def        __lowercase     (	self :   Any					):

													"""simple docstring"""
													pass







						@unittest.skip('''Esm does not support embedding resizing'''					)
						def        __lowercase     (	self :   int					):

													"""simple docstring"""
													pass







						@unittest.skip('''ESMFold does not support passing input embeds!'''					)
						def        __lowercase     (	self :   Dict					):

													"""simple docstring"""
													pass







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

													"""simple docstring"""
													pass







						@unittest.skip('''ESMFold does not support head pruning.'''					)
						def        __lowercase     (	self :   Tuple					):

													"""simple docstring"""
													pass







						@unittest.skip('''ESMFold does not support head pruning.'''					)
						def        __lowercase     (	self :   Optional[Any]					):

													"""simple docstring"""
													pass







						@unittest.skip('''ESMFold does not support head pruning.'''					)
						def        __lowercase     (	self :   str					):

													"""simple docstring"""
													pass







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

													"""simple docstring"""
													pass







						@unittest.skip('''ESMFold does not output hidden states in the normal way.'''					)
						def        __lowercase     (	self :   Optional[int]					):

													"""simple docstring"""
													pass







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

													"""simple docstring"""
													pass







						@unittest.skip('''ESMFold only has one output format.'''					)
						def        __lowercase     (	self :   Union[str, Any]					):

													"""simple docstring"""
													pass







						@unittest.skip('''This test doesn\'t work for ESMFold and doesn\'t test core functionality'''					)
						def        __lowercase     (	self :   List[Any]					):

													"""simple docstring"""
													pass







						@unittest.skip('''ESMFold does not support input chunking.'''					)
						def        __lowercase     (	self :   Dict					):

													"""simple docstring"""
													pass







						@unittest.skip('''ESMFold doesn\'t respect you and it certainly doesn\'t respect your initialization arguments.'''					)
						def        __lowercase     (	self :   Any					):

													"""simple docstring"""
													pass







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

													"""simple docstring"""
													pass







						@unittest.skip('''ESMFold doesn\'t support torchscript compilation.'''					)
						def        __lowercase     (	self :   Any					):

													"""simple docstring"""
													pass







						@unittest.skip('''ESMFold doesn\'t support torchscript compilation.'''					)
						def        __lowercase     (	self :   Any					):

													"""simple docstring"""
													pass







						@unittest.skip('''ESMFold doesn\'t support data parallel.'''					)
						def        __lowercase     (	self :   Optional[int]					):

													"""simple docstring"""
													pass







						@unittest.skip('''Will be fixed soon by reducing the size of the model used for common tests.'''					)
						def        __lowercase     (	self :   List[Any]					):

													"""simple docstring"""
													pass


@require_torch
class 						lowerCamelCase_				(       snake_case_      ):







						@slow
						def        __lowercase     (	self :   Optional[int]					):

													"""simple docstring"""
													SCREAMING_SNAKE_CASE       :   List[str]         =      EsmForProteinFolding.from_pretrained('''facebook/esmfold_v1'''					).float()
													model.eval()
													SCREAMING_SNAKE_CASE       :   str         =      torch.tensor([[0, 6, 4, 13, 5, 4, 16, 12, 11, 7, 2]]					)
													SCREAMING_SNAKE_CASE       :   Optional[int]         =      model(lowerCAmelCase__					)['''positions''']
													SCREAMING_SNAKE_CASE       :   Dict         =      torch.tensor([2.5828, 0.7993, -10.9334]					,     dtype=torch.floataa					)
													self.assertTrue(torch.allclose(position_outputs[0, 0, 0, 0]					,     lowerCAmelCase__					,     atol=1e-4					)					)









'''simple docstring'''



def        UpperCAmelCase (    A	:					int					):
							if not isinstance(A       ,		A					):
														SCREAMING_SNAKE_CASE       :   List[str]         =      F"""Input value of [number={number}] must be an integer"""
														raise TypeError(A					)
							if number < 0:
														return False
							SCREAMING_SNAKE_CASE       :   List[str]         =      number * number
							while number > 0:
														if number % 10 != number_square % 10:
																					return False
														number //= 10
														number_square //= 10
							return True


if __name__ == "__main__":
							import doctest

							doctest.testmod()




