



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



 '''simple docstring'''







 def __init__(self					,  A					,  A=13					,  A=7					,  A=False					,  A=True					,  A=False					,  A=False					,  A=19					,  A=32					,  A=5					,  A=4					,  A=37					,  A="gelu"					,  A=0.1					,  A=0.1					,  A=512					,  A=16					,  A=2					,  A=0.02					,  A=3					,  A=4					,  A=None					,  )       ->	str:


      """simple docstring"""



      _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    a__    (self			)       ->	List[str]:


      """simple docstring"""



      _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    a__    (self			)       ->	Tuple:


      """simple docstring"""



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



 def    a__    (self					,  A					,  A					,  A					,  A					,  A					,  A			)       ->	Dict:


      """simple docstring"""



      _a           =    EsmForProteinFolding(config=A			).float()
      model.to(A			)
      model.eval()
      _a           =    model(A					,  attention_mask=A			)
      _a           =    model(A			)
      _a           =    model(A			)

      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			)       ->	int:


      """simple docstring"""



      _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 __A     (    A  ,  A  ,  unittest.TestCase		):



 '''simple docstring'''







 __lowerCamelCase       :			Tuple		=			False

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



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


      """simple docstring"""



      _a           =    EsmFoldModelTester(self			)
      _a           =    ConfigTester(self					,  config_class=A					,  hidden_size=37			)



 def    a__    (self			)       ->	int:


      """simple docstring"""



      self.config_tester.run_common_tests()



 def    a__    (self			)       ->	int:


      """simple docstring"""



      _a           =    self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_model(*A			)



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


      """simple docstring"""



      pass



 @unittest.skip
 def    a__    (self			)       ->	Tuple:


      """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			)       ->	List[str]:


      """simple docstring"""



      pass



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


      """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			)       ->	str:


      """simple docstring"""



      pass



 @unittest.skip('''ESMFold does not support head pruning.'''			)
 def    a__    (self			)       ->	Optional[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			)       ->	Union[str, Any]:


      """simple docstring"""



      pass



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


      """simple docstring"""



      pass



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


      """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			)       ->	List[str]:


      """simple docstring"""



      pass



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


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


      """simple docstring"""



      pass



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


      """simple docstring"""



      pass



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


      """simple docstring"""



      pass



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


      """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     (    A		):



 '''simple docstring'''







 @slow
 def    a__    (self			)       ->	Optional[Any]:


      """simple docstring"""



      _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(A			)['''positions''']
      _a           =    torch.tensor([2.5828, 0.7993, -10.9334]					,  dtype=torch.floataa			)
      self.assertTrue(torch.allclose(position_outputs[0, 0, 0, 0]					,  A					,  atol=1E-4			)			)








"""simple docstring"""







from ..utils import (
    OptionalDependencyNotAvailable,
    is_flax_available,
    is_scipy_available,
    is_torch_available,
    is_torchsde_available,
)


try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			from ..utils.dummy_pt_objects import *  # noqa F403
else:
			from .scheduling_consistency_models import CMStochasticIterativeScheduler
			from .scheduling_ddim import DDIMScheduler
			from .scheduling_ddim_inverse import DDIMInverseScheduler
			from .scheduling_ddim_parallel import DDIMParallelScheduler
			from .scheduling_ddpm import DDPMScheduler
			from .scheduling_ddpm_parallel import DDPMParallelScheduler
			from .scheduling_deis_multistep import DEISMultistepScheduler
			from .scheduling_dpmsolver_multistep import DPMSolverMultistepScheduler
			from .scheduling_dpmsolver_multistep_inverse import DPMSolverMultistepInverseScheduler
			from .scheduling_dpmsolver_singlestep import DPMSolverSinglestepScheduler
			from .scheduling_euler_ancestral_discrete import EulerAncestralDiscreteScheduler
			from .scheduling_euler_discrete import EulerDiscreteScheduler
			from .scheduling_heun_discrete import HeunDiscreteScheduler
			from .scheduling_ipndm import IPNDMScheduler
			from .scheduling_k_dpm_2_ancestral_discrete import KDPMaAncestralDiscreteScheduler
			from .scheduling_k_dpm_2_discrete import KDPMaDiscreteScheduler
			from .scheduling_karras_ve import KarrasVeScheduler
			from .scheduling_pndm import PNDMScheduler
			from .scheduling_repaint import RePaintScheduler
			from .scheduling_sde_ve import ScoreSdeVeScheduler
			from .scheduling_sde_vp import ScoreSdeVpScheduler
			from .scheduling_unclip import UnCLIPScheduler
			from .scheduling_unipc_multistep import UniPCMultistepScheduler
			from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin
			from .scheduling_vq_diffusion import VQDiffusionScheduler

try:
			if not is_flax_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			from ..utils.dummy_flax_objects import *  # noqa F403
else:
			from .scheduling_ddim_flax import FlaxDDIMScheduler
			from .scheduling_ddpm_flax import FlaxDDPMScheduler
			from .scheduling_dpmsolver_multistep_flax import FlaxDPMSolverMultistepScheduler
			from .scheduling_karras_ve_flax import FlaxKarrasVeScheduler
			from .scheduling_lms_discrete_flax import FlaxLMSDiscreteScheduler
			from .scheduling_pndm_flax import FlaxPNDMScheduler
			from .scheduling_sde_ve_flax import FlaxScoreSdeVeScheduler
			from .scheduling_utils_flax import (
			    FlaxKarrasDiffusionSchedulers,
			    FlaxSchedulerMixin,
			    FlaxSchedulerOutput,
			    broadcast_to_shape_from_left,
			)


try:
			if not (is_torch_available() and is_scipy_available()):
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			from ..utils.dummy_torch_and_scipy_objects import *  # noqa F403
else:
			from .scheduling_lms_discrete import LMSDiscreteScheduler

try:
			if not (is_torch_available() and is_torchsde_available()):
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			from ..utils.dummy_torch_and_torchsde_objects import *  # noqa F403
else:
			from .scheduling_dpmsolver_sde import DPMSolverSDEScheduler




