






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






           """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   _SCREAMING_SNAKE_CASE     ( self      :    Optional[int] ):






           """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   _SCREAMING_SNAKE_CASE     ( self      :    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   _SCREAMING_SNAKE_CASE     ( self      :    List[str]   ,						_SCREAMING_SNAKE_CASE      :    Any   ,						_SCREAMING_SNAKE_CASE      :    Optional[int]   ,						_SCREAMING_SNAKE_CASE      :    List[str]   ,						_SCREAMING_SNAKE_CASE      :    int   ,						_SCREAMING_SNAKE_CASE      :    Dict   ,						_SCREAMING_SNAKE_CASE      :    Optional[Any] ):






           """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   _SCREAMING_SNAKE_CASE     ( 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__     (     __snake_case   ,    __snake_case   ,    unittest.TestCase ):

     '''simple docstring'''






     snake_case__					=					False

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







     def   _SCREAMING_SNAKE_CASE     ( self      :    Optional[int] ):






           """simple docstring"""




           UpperCamelCase					       =  EsmFoldModelTester(self )
           UpperCamelCase					       =  ConfigTester(self   ,						config_class=_SCREAMING_SNAKE_CASE   ,						hidden_size=37 )







     def   _SCREAMING_SNAKE_CASE     ( self      :    int ):






           """simple docstring"""




           self.config_tester.run_common_tests()







     def   _SCREAMING_SNAKE_CASE     ( self      :    Optional[Any] ):






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






           """simple docstring"""




           pass







     @unittest.skip
     def   _SCREAMING_SNAKE_CASE     ( self      :    int ):






           """simple docstring"""




           pass







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






           """simple docstring"""




           pass







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






           """simple docstring"""




           pass







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






           """simple docstring"""




           pass







     @unittest.skip('ESMFold does not support head pruning.' )
     def   _SCREAMING_SNAKE_CASE     ( self      :    List[str] ):






           """simple docstring"""




           pass







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






           """simple docstring"""




           pass







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






           """simple docstring"""




           pass







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






           """simple docstring"""




           pass







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






           """simple docstring"""




           pass







     @unittest.skip('ESMFold does not output hidden states in the normal way.' )
     def   _SCREAMING_SNAKE_CASE     ( self      :    Any ):






           """simple docstring"""




           pass







     @unittest.skip('ESMfold does not output hidden states in the normal way.' )
     def   _SCREAMING_SNAKE_CASE     ( self      :    Any ):






           """simple docstring"""




           pass







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






           """simple docstring"""




           pass







     @unittest.skip('This test doesn\'t work for ESMFold and doesn\'t test core functionality' )
     def   _SCREAMING_SNAKE_CASE     ( self      :    Optional[int] ):






           """simple docstring"""




           pass







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






           """simple docstring"""




           pass







     @unittest.skip('ESMFold doesn\'t respect you and it certainly doesn\'t respect your initialization arguments.' )
     def   _SCREAMING_SNAKE_CASE     ( self      :    Union[str, Any] ):






           """simple docstring"""




           pass







     @unittest.skip('ESMFold doesn\'t support torchscript compilation.' )
     def   _SCREAMING_SNAKE_CASE     ( self      :    List[str] ):






           """simple docstring"""




           pass







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






           """simple docstring"""




           pass







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






           """simple docstring"""




           pass







     @unittest.skip('ESMFold doesn\'t support data parallel.' )
     def   _SCREAMING_SNAKE_CASE     ( self      :    Any ):






           """simple docstring"""




           pass







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






           """simple docstring"""




           pass





@require_torch
class 					A__     (     __snake_case ):

     '''simple docstring'''






     @slow
     def   _SCREAMING_SNAKE_CASE     ( self      :    List[str] ):






           """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.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]   ,						_SCREAMING_SNAKE_CASE   ,						atol=1E-4 ) )











__magic_name__   :  str        =							8.314_4598
def 		lowercase__  (				_UpperCamelCase       ,							_UpperCamelCase) ->			float:
      """simple docstring"""

      if temperature < 0:
            raise Exception('Temperature cannot be less than 0 K')
      if molar_mass <= 0:
            raise Exception('Molar mass cannot be less than or equal to 0 kg/mol')
      else:
            return (3 * UNIVERSAL_GAS_CONSTANT * temperature / molar_mass) ** 0.5


if __name__ == "__main__":
       import doctest

       # run doctest
       doctest.testmod()

       # example
       __magic_name__   :  List[Any]        =							300
       __magic_name__   :  Union[str, Any]        =							28
       __magic_name__   :  str        =							rms_speed_of_molecule(temperature, molar_mass)
       print(F'Vrms of Nitrogen gas at 300 K is {vrms} m/s')



