


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



					'''simple docstring'''







					def __init__(				self ,       snake_case_ ,       snake_case_=1_3 ,       snake_case_=7 ,       snake_case_=False ,       snake_case_=True ,       snake_case_=False ,       snake_case_=False ,       snake_case_=1_9 ,       snake_case_=3_2 ,       snake_case_=5 ,       snake_case_=4 ,       snake_case_=3_7 ,       snake_case_="gelu" ,       snake_case_=0.1 ,       snake_case_=0.1 ,       snake_case_=5_1_2 ,       snake_case_=1_6 ,       snake_case_=2 ,       snake_case_=0.0_2 ,       snake_case_=3 ,       snake_case_=4 ,       snake_case_=None ,       )   ->			Dict:







								'''simple docstring'''

								__lowercase 					=   parent
								__lowercase 					=   batch_size
								__lowercase 					=   seq_length
								__lowercase 					=   is_training
								__lowercase 					=   use_input_mask
								__lowercase 					=   use_token_type_ids
								__lowercase 					=   use_labels
								__lowercase 					=   vocab_size
								__lowercase 					=   hidden_size
								__lowercase 					=   num_hidden_layers
								__lowercase 					=   num_attention_heads
								__lowercase 					=   intermediate_size
								__lowercase 					=   hidden_act
								__lowercase 					=   hidden_dropout_prob
								__lowercase 					=   attention_probs_dropout_prob
								__lowercase 					=   max_position_embeddings
								__lowercase 					=   type_vocab_size
								__lowercase 					=   type_sequence_label_size
								__lowercase 					=   initializer_range
								__lowercase 					=   num_labels
								__lowercase 					=   num_choices
								__lowercase 					=   scope






					def A      (				self						)   ->			Union[str, Any]:







								'''simple docstring'''

								__lowercase 					=   ids_tensor([self.batch_size, self.seq_length] ,       self.vocab_size						)

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

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

								__lowercase 					=   self.get_config()

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






					def A      (				self						)   ->			Tuple:







								'''simple docstring'''

								__lowercase 					=   EsmConfig(
								    vocab_size=3_3 ,       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=snake_case_ ,       esmfold_config={'''trunk''': {'''num_blocks''': 2}, '''fp16_esm''': False} ,       )
								return config






					def A      (				self ,       snake_case_ ,       snake_case_ ,       snake_case_ ,       snake_case_ ,       snake_case_ ,       snake_case_						)   ->			Optional[Any]:







								'''simple docstring'''

								__lowercase 					=   EsmForProteinFolding(config=snake_case_						).float()
								model.to(snake_case_						)
								model.eval()
								__lowercase 					=   model(snake_case_ ,       attention_mask=snake_case_						)
								__lowercase 					=   model(snake_case_						)
								__lowercase 					=   model(snake_case_						)

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






					def A      (				self						)   ->			Union[str, Any]:







								'''simple docstring'''

								__lowercase 					=   self.prepare_config_and_inputs()
								(
								    (
								    __lowercase 
								)					, (
								    __lowercase 
								)					, (
								    __lowercase 
								)					, (
								    __lowercase 
								)					, (
								    __lowercase 
								)					, (
								    __lowercase 
								)					,  
								) 					=   config_and_inputs
								__lowercase 					=   {'''input_ids''': input_ids, '''attention_mask''': input_mask}
								return config, inputs_dict




@require_torch
class 	lowerCamelCase_       (				lowerCAmelCase__     ,     lowerCAmelCase__     ,     unittest.TestCase				):



					'''simple docstring'''







					__UpperCAmelCase            =				False

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






					def A      (				self						)   ->			Dict:







								'''simple docstring'''

								__lowercase 					=   EsmFoldModelTester(self						)
								__lowercase 					=   ConfigTester(self ,       config_class=snake_case_ ,       hidden_size=3_7						)






					def A      (				self						)   ->			List[Any]:







								'''simple docstring'''

								self.config_tester.run_common_tests()






					def A      (				self						)   ->			List[Any]:







								'''simple docstring'''

								__lowercase 					=   self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_model(*snake_case_						)






					@unittest.skip('''Does not support attention outputs'''						)
					def A      (				self						)   ->			List[str]:







								'''simple docstring'''

								pass






					@unittest.skip
					def A      (				self						)   ->			List[str]:







								'''simple docstring'''

								pass






					@unittest.skip('''Esm does not support embedding resizing'''						)
					def A      (				self						)   ->			Optional[int]:







								'''simple docstring'''

								pass






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







								'''simple docstring'''

								pass






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







								'''simple docstring'''

								pass






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







								'''simple docstring'''

								pass






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







								'''simple docstring'''

								pass






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







								'''simple docstring'''

								pass






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







								'''simple docstring'''

								pass






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







								'''simple docstring'''

								pass






					@unittest.skip('''ESMFold does not output hidden states in the normal way.'''						)
					def A      (				self						)   ->			List[Any]:







								'''simple docstring'''

								pass






					@unittest.skip('''ESMfold does not output hidden states in the normal way.'''						)
					def A      (				self						)   ->			List[Any]:







								'''simple docstring'''

								pass






					@unittest.skip('''ESMFold only has one output format.'''						)
					def A      (				self						)   ->			str:







								'''simple docstring'''

								pass






					@unittest.skip('''This test doesn\'t work for ESMFold and doesn\'t test core functionality'''						)
					def A      (				self						)   ->			Union[str, Any]:







								'''simple docstring'''

								pass






					@unittest.skip('''ESMFold does not support input chunking.'''						)
					def A      (				self						)   ->			int:







								'''simple docstring'''

								pass






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







								'''simple docstring'''

								pass






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







								'''simple docstring'''

								pass






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







								'''simple docstring'''

								pass






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







								'''simple docstring'''

								pass






					@unittest.skip('''ESMFold doesn\'t support data parallel.'''						)
					def A      (				self						)   ->			List[str]:







								'''simple docstring'''

								pass






					@unittest.skip('''Will be fixed soon by reducing the size of the model used for common tests.'''						)
					def A      (				self						)   ->			Dict:







								'''simple docstring'''

								pass




@require_torch
class 	lowerCamelCase_       (				lowerCAmelCase__				):



					'''simple docstring'''







					@slow
					def A      (				self						)   ->			List[str]:







								'''simple docstring'''

								__lowercase 					=   EsmForProteinFolding.from_pretrained('''facebook/esmfold_v1'''						).float()
								model.eval()
								__lowercase 					=   torch.tensor([[0, 6, 4, 1_3, 5, 4, 1_6, 1_2, 1_1, 7, 2]]						)
								__lowercase 					=   model(snake_case_						)['''positions''']
								__lowercase 					=   torch.tensor([2.5_8_2_8, 0.7_9_9_3, -1_0.9_3_3_4] ,       dtype=torch.floataa						)
								self.assertTrue(torch.allclose(position_outputs[0, 0, 0, 0] ,       snake_case_ ,       atol=1e-4						)						)






# limitations under the License.

# NOTE: This file is deprecated and will be removed in a future version.
# It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works

from .pipelines import DiffusionPipeline, ImagePipelineOutput  # noqa: F401
from .utils import deprecate


deprecate(
    '''pipelines_utils''',
    '''0.22.0''',
    '''Importing `DiffusionPipeline` or `ImagePipelineOutput` from diffusers.pipeline_utils is deprecated. Please import from diffusers.pipelines.pipeline_utils instead.''',
    standard_warn=False,
    stacklevel=3,
)


