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   ,				SCREAMING_SNAKE_CASE_   ,				SCREAMING_SNAKE_CASE_=13   ,				SCREAMING_SNAKE_CASE_=7   ,				SCREAMING_SNAKE_CASE_=False   ,				SCREAMING_SNAKE_CASE_=True   ,				SCREAMING_SNAKE_CASE_=False   ,				SCREAMING_SNAKE_CASE_=False   ,				SCREAMING_SNAKE_CASE_=19   ,				SCREAMING_SNAKE_CASE_=32   ,				SCREAMING_SNAKE_CASE_=5   ,				SCREAMING_SNAKE_CASE_=4   ,				SCREAMING_SNAKE_CASE_=37   ,				SCREAMING_SNAKE_CASE_="gelu"   ,				SCREAMING_SNAKE_CASE_=0.1   ,				SCREAMING_SNAKE_CASE_=0.1   ,				SCREAMING_SNAKE_CASE_=512   ,				SCREAMING_SNAKE_CASE_=16   ,				SCREAMING_SNAKE_CASE_=2   ,				SCREAMING_SNAKE_CASE_=0.02   ,				SCREAMING_SNAKE_CASE_=3   ,				SCREAMING_SNAKE_CASE_=4   ,				SCREAMING_SNAKE_CASE_=None   ,				)		->      Any:





       '''simple docstring'''





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






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





       '''simple docstring'''





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

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

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

       UpperCamelCase__										=      self.get_config()

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






  def 		_a					(self	)		->      Optional[int]:





       '''simple docstring'''





       UpperCamelCase__										=      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=SCREAMING_SNAKE_CASE_   ,				esmfold_config={'''trunk''': {'''num_blocks''': 2}, '''fp16_esm''': False}   ,				)
       return config






  def 		_a					(self   ,				SCREAMING_SNAKE_CASE_   ,				SCREAMING_SNAKE_CASE_   ,				SCREAMING_SNAKE_CASE_   ,				SCREAMING_SNAKE_CASE_   ,				SCREAMING_SNAKE_CASE_   ,				SCREAMING_SNAKE_CASE_	)		->      str:





       '''simple docstring'''





       UpperCamelCase__										=      EsmForProteinFolding(config=SCREAMING_SNAKE_CASE_	).float()
       model.to(SCREAMING_SNAKE_CASE_	)
       model.eval()
       UpperCamelCase__										=      model(SCREAMING_SNAKE_CASE_   ,				attention_mask=SCREAMING_SNAKE_CASE_	)
       UpperCamelCase__										=      model(SCREAMING_SNAKE_CASE_	)
       UpperCamelCase__										=      model(SCREAMING_SNAKE_CASE_	)

       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 		_a					(self	)		->      Union[str, Any]:





       '''simple docstring'''





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



@require_torch
class     _A   (    __UpperCamelCase	, __UpperCamelCase	, unittest.TestCase							):
  SCREAMING_SNAKE_CASE_	:	int						=False

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






  def 		_a					(self	)		->      int:





       '''simple docstring'''





       UpperCamelCase__										=      EsmFoldModelTester(self	)
       UpperCamelCase__										=      ConfigTester(self   ,				config_class=SCREAMING_SNAKE_CASE_   ,				hidden_size=37	)






  def 		_a					(self	)		->      int:





       '''simple docstring'''





       self.config_tester.run_common_tests()






  def 		_a					(self	)		->      Tuple:





       '''simple docstring'''





       UpperCamelCase__										=      self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE_	)






  @unittest.skip('''Does not support attention outputs'''	)
  def 		_a					(self	)		->      str:





       '''simple docstring'''





       pass






  @unittest.skip
  def 		_a					(self	)		->      Any:





       '''simple docstring'''





       pass






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





       '''simple docstring'''





       pass






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





       '''simple docstring'''





       pass






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





       '''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	)		->      Optional[Any]:





       '''simple docstring'''





       pass






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





       '''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	)		->      Optional[int]:





       '''simple docstring'''





       pass






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





       '''simple docstring'''





       pass






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





       '''simple docstring'''





       pass






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





       '''simple docstring'''





       pass






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





       '''simple docstring'''





       pass






  @unittest.skip('''ESMFold does not support input chunking.'''	)
  def 		_a					(self	)		->      Union[str, Any]:





       '''simple docstring'''





       pass






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





       '''simple docstring'''





       pass






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





       '''simple docstring'''





       pass






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





       '''simple docstring'''





       pass






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





       '''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	)		->      Optional[Any]:





       '''simple docstring'''





       pass



@require_torch
class     _A   (    __UpperCamelCase							):






  @slow
  def 		_a					(self	)		->      Any:





       '''simple docstring'''





       UpperCamelCase__										=      EsmForProteinFolding.from_pretrained('''facebook/esmfold_v1'''	).float()
       model.eval()
       UpperCamelCase__										=      torch.tensor([[0, 6, 4, 13, 5, 4, 16, 12, 11, 7, 2]]	)
       UpperCamelCase__										=      model(SCREAMING_SNAKE_CASE_	)['''positions''']
       UpperCamelCase__										=      torch.tensor([2.5828, 0.7993, -10.9334]   ,				dtype=torch.floataa	)
       self.assertTrue(torch.allclose(position_outputs[0, 0, 0, 0]   ,				SCREAMING_SNAKE_CASE_   ,				atol=1E-4	)	)




def  __UpperCamelCase    (						A = 600851475143							):

     try:
          UpperCamelCase__										=      int(A							)
     except (TypeError, ValueError):
          raise TypeError('''Parameter n must be int or castable to int.'''							)
     if n <= 0:
          raise ValueError('''Parameter n must be greater than or equal to one.'''							)
     UpperCamelCase__										=      1
     UpperCamelCase__										=      2
     while i * i <= n:
          while n % i == 0:
               UpperCamelCase__										=      i
               n //= i
          i += 1
     if n > 1:
          UpperCamelCase__										=      n
     return int(A							)


if __name__ == "__main__":
     print(f"""{solution() = }""")



