



"""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 					a	:



  def __init__(						self :					List[Any]       ,		lowerCAmelCase :					str       ,		lowerCAmelCase :					List[str]=13       ,		lowerCAmelCase :					Optional[Any]=7       ,		lowerCAmelCase :					str=False       ,		lowerCAmelCase :					Union[str, Any]=True       ,		lowerCAmelCase :					List[Any]=False       ,		lowerCAmelCase :					Dict=False       ,		lowerCAmelCase :					Dict=19       ,		lowerCAmelCase :					Dict=32       ,		lowerCAmelCase :					Dict=5       ,		lowerCAmelCase :					List[str]=4       ,		lowerCAmelCase :					Any=37       ,		lowerCAmelCase :					List[Any]="gelu"       ,		lowerCAmelCase :					Tuple=0.1       ,		lowerCAmelCase :					str=0.1       ,		lowerCAmelCase :					List[str]=512       ,		lowerCAmelCase :					List[Any]=16       ,		lowerCAmelCase :					List[Any]=2       ,		lowerCAmelCase :					Dict=0.0_2       ,		lowerCAmelCase :					int=3       ,		lowerCAmelCase :					Optional[int]=4       ,		lowerCAmelCase :					Optional[int]=None       ,		)     ->					Optional[Any]:


     '''simple docstring'''




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



  def 	lowerCamelCase__       (						self :					int		)     ->					List[str]:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_: Dict     			=ids_tensor([self.batch_size, self.seq_length]       ,		self.vocab_size		)

     SCREAMING_SNAKE_CASE_: Optional[int]     			=None
     if self.use_input_mask:
        SCREAMING_SNAKE_CASE_: Optional[Any]     			=random_attention_mask([self.batch_size, self.seq_length]		)

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

     SCREAMING_SNAKE_CASE_: List[Any]     			=self.get_config()

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



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


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_: str     			=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 	lowerCamelCase__       (						self :					Union[str, Any]       ,		lowerCAmelCase :					Any       ,		lowerCAmelCase :					Tuple       ,		lowerCAmelCase :					str       ,		lowerCAmelCase :					Any       ,		lowerCAmelCase :					Union[str, Any]       ,		lowerCAmelCase :					List[Any]		)     ->					Optional[Any]:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_: Union[str, Any]     			=EsmForProteinFolding(config=lowerCAmelCase		).float()
     model.to(lowerCAmelCase		)
     model.eval()
     SCREAMING_SNAKE_CASE_: Union[str, Any]     			=model(lowerCAmelCase       ,		attention_mask=lowerCAmelCase		)
     SCREAMING_SNAKE_CASE_: str     			=model(lowerCAmelCase		)
     SCREAMING_SNAKE_CASE_: Optional[Any]     			=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 	lowerCamelCase__       (						self :					List[str]		)     ->					Dict:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_: Dict     			=self.prepare_config_and_inputs()
     (
         SCREAMING_SNAKE_CASE_		
     ): Any     			=config_and_inputs
     SCREAMING_SNAKE_CASE_: int     			={"""input_ids""": input_ids, """attention_mask""": input_mask}
     return config, inputs_dict







@require_torch
class 					a	(  UpperCAmelCase__	,      UpperCAmelCase__	,      unittest.TestCase       ):
  UpperCamelCase	:				List[str]     						=					False

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



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


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_: Tuple     			=EsmFoldModelTester(self		)
     SCREAMING_SNAKE_CASE_: Tuple     			=ConfigTester(self       ,		config_class=lowerCAmelCase       ,		hidden_size=37		)



  def 	lowerCamelCase__       (						self :					Optional[Any]		)     ->					str:


     '''simple docstring'''




     self.config_tester.run_common_tests()



  def 	lowerCamelCase__       (						self :					str		)     ->					List[str]:


     '''simple docstring'''




     SCREAMING_SNAKE_CASE_: List[str]     			=self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_model(*lowerCAmelCase		)



  @unittest.skip("""Does not support attention outputs"""		)
  def 	lowerCamelCase__       (						self :					Any		)     ->					Optional[int]:


     '''simple docstring'''




     pass



  @unittest.skip
  def 	lowerCamelCase__       (						self :					Tuple		)     ->					List[Any]:


     '''simple docstring'''




     pass



  @unittest.skip("""Esm does not support embedding resizing"""		)
  def 	lowerCamelCase__       (						self :					Optional[Any]		)     ->					List[Any]:


     '''simple docstring'''




     pass



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


     '''simple docstring'''




     pass



  @unittest.skip("""ESMFold does not support passing input embeds!"""		)
  def 	lowerCamelCase__       (						self :					Dict		)     ->					Optional[Any]:


     '''simple docstring'''




     pass



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


     '''simple docstring'''




     pass



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


     '''simple docstring'''




     pass



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


     '''simple docstring'''




     pass



  @unittest.skip("""ESMFold does not support head pruning."""		)
  def 	lowerCamelCase__       (						self :					List[str]		)     ->					Dict:


     '''simple docstring'''




     pass



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


     '''simple docstring'''




     pass



  @unittest.skip("""ESMFold does not output hidden states in the normal way."""		)
  def 	lowerCamelCase__       (						self :					Any		)     ->					str:


     '''simple docstring'''




     pass



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


     '''simple docstring'''




     pass



  @unittest.skip("""ESMFold only has one output format."""		)
  def 	lowerCamelCase__       (						self :					Dict		)     ->					Optional[int]:


     '''simple docstring'''




     pass



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


     '''simple docstring'''




     pass



  @unittest.skip("""ESMFold does not support input chunking."""		)
  def 	lowerCamelCase__       (						self :					Optional[int]		)     ->					List[str]:


     '''simple docstring'''




     pass



  @unittest.skip("""ESMFold doesn't respect you and it certainly doesn't respect your initialization arguments."""		)
  def 	lowerCamelCase__       (						self :					List[Any]		)     ->					Optional[int]:


     '''simple docstring'''




     pass



  @unittest.skip("""ESMFold doesn't support torchscript compilation."""		)
  def 	lowerCamelCase__       (						self :					str		)     ->					Dict:


     '''simple docstring'''




     pass



  @unittest.skip("""ESMFold doesn't support torchscript compilation."""		)
  def 	lowerCamelCase__       (						self :					Any		)     ->					int:


     '''simple docstring'''




     pass



  @unittest.skip("""ESMFold doesn't support torchscript compilation."""		)
  def 	lowerCamelCase__       (						self :					Optional[int]		)     ->					List[Any]:


     '''simple docstring'''




     pass



  @unittest.skip("""ESMFold doesn't support data parallel."""		)
  def 	lowerCamelCase__       (						self :					Any		)     ->					List[Any]:


     '''simple docstring'''




     pass





  @unittest.skip("""Will be fixed soon by reducing the size of the model used for common tests."""		)
  def 	lowerCamelCase__       (						self :					str		)     ->					Optional[Any]:


     '''simple docstring'''




     pass







@require_torch
class 					a	(  UpperCAmelCase__       ):



  @slow
  def 	lowerCamelCase__       (						self :					List[Any]		)     ->					Dict:


     '''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_: List[str]     			=torch.tensor([2.5_8_2_8, 0.7_9_9_3, -10.9334]       ,		dtype=torch.floataa		)
     self.assertTrue(torch.allclose(position_outputs[0, 0, 0, 0]       ,		lowerCAmelCase       ,		atol=1E-4		)		)








"""simple docstring"""
def      __magic_name__				(							lowercase							,			lowercase ):
   return int((input_a, input_a).count(0 ) == 0 )





def      __magic_name__				(							):
   assert and_gate(0							,			0 ) == 0
   assert and_gate(0							,			1 ) == 0
   assert and_gate(1							,			0 ) == 0
   assert and_gate(1							,			1 ) == 1


if __name__ == "__main__":
   test_and_gate()
   print(and_gate(1, 0))
   print(and_gate(0, 0))
   print(and_gate(0, 1))
   print(and_gate(1, 1))



