




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







 '''simple docstring'''





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




   '''simple docstring'''



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


 def 					UpperCamelCase_  (							self:						Optional[int]						):




   '''simple docstring'''



   _snake_case				:						Optional[int]								=    ids_tensor([self.batch_size, self.seq_length], self.vocab_size						)

   _snake_case				:						Tuple								=    None
   if self.use_input_mask:
     _snake_case				:						str								=    random_attention_mask([self.batch_size, self.seq_length]						)

   _snake_case				:						Union[str, Any]								=    None
   _snake_case				:						Optional[Any]								=    None
   _snake_case				:						List[str]								=    None
   if self.use_labels:
     _snake_case				:						Tuple								=    ids_tensor([self.batch_size], self.type_sequence_label_size						)
     _snake_case				:						List[str]								=    ids_tensor([self.batch_size, self.seq_length], self.num_labels						)
     _snake_case				:						Optional[int]								=    ids_tensor([self.batch_size], self.num_choices						)

   _snake_case				:						Optional[Any]								=    self.get_config()

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


 def 					UpperCamelCase_  (							self:						int						):




   '''simple docstring'''



   _snake_case				:						Tuple								=    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 					UpperCamelCase_  (							self:						List[str], a_:						Any, a_:						Optional[int], a_:						List[str], a_:						int, a_:						Dict, a_:						Optional[Any]						):




   '''simple docstring'''



   _snake_case				:						Union[str, Any]								=    EsmForProteinFolding(config=_SCREAMING_SNAKE_CASE						).float()
   model.to(_SCREAMING_SNAKE_CASE						)
   model.eval()
   _snake_case				:						List[str]								=    model(_SCREAMING_SNAKE_CASE, attention_mask=_SCREAMING_SNAKE_CASE						)
   _snake_case				:						Union[str, Any]								=    model(_SCREAMING_SNAKE_CASE						)
   _snake_case				:						str								=    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 					UpperCamelCase_  (							self:						Union[str, Any]						):




   '''simple docstring'''



   _snake_case				:						List[Any]								=    self.prepare_config_and_inputs()
   (
       (
       _snake_case  
   )						,   (
       _snake_case  
   )						,   (
       _snake_case  
   )						,   (
       _snake_case  
   )						,   (
       _snake_case  
   )						,   (
       _snake_case  
   )						,     
   )				:						int								=    config_and_inputs
   _snake_case				:						Optional[Any]								=    {"""input_ids""": input_ids, """attention_mask""": input_mask}
   return config, inputs_dict







@require_torch
class    lowercase(	__snake_case			,     __snake_case			,     unittest.TestCase					):







 '''simple docstring'''





 lowercase__					   =   False

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


 def 					UpperCamelCase_  (							self:						Optional[int]						):




   '''simple docstring'''



   _snake_case				:						Optional[int]								=    EsmFoldModelTester(self						)
   _snake_case				:						List[Any]								=    ConfigTester(self, config_class=_SCREAMING_SNAKE_CASE, hidden_size=37						)


 def 					UpperCamelCase_  (							self:						int						):




   '''simple docstring'''



   self.config_tester.run_common_tests()


 def 					UpperCamelCase_  (							self:						Optional[Any]						):




   '''simple docstring'''



   _snake_case				:						Any								=    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 					UpperCamelCase_  (							self:						str						):




   '''simple docstring'''



   pass


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




   '''simple docstring'''



   pass


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




   '''simple docstring'''



   pass


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




   '''simple docstring'''



   pass


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




   '''simple docstring'''



   pass


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




   '''simple docstring'''



   pass


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




   '''simple docstring'''



   pass


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




   '''simple docstring'''



   pass


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




   '''simple docstring'''



   pass


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




   '''simple docstring'''



   pass


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




   '''simple docstring'''



   pass


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




   '''simple docstring'''



   pass


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




   '''simple docstring'''



   pass


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




   '''simple docstring'''



   pass


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




   '''simple docstring'''



   pass


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




   '''simple docstring'''



   pass


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




   '''simple docstring'''



   pass


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




   '''simple docstring'''



   pass


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




   '''simple docstring'''



   pass


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




   '''simple docstring'''



   pass


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




   '''simple docstring'''



   pass







@require_torch
class    lowercase(	__snake_case					):







 '''simple docstring'''





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




   '''simple docstring'''



   _snake_case				:						List[Any]								=    EsmForProteinFolding.from_pretrained("""facebook/esmfold_v1"""						).float()
   model.eval()
   _snake_case				:						Any								=    torch.tensor([[0, 6, 4, 13, 5, 4, 16, 12, 11, 7, 2]]						)
   _snake_case				:						Optional[Any]								=    model(_SCREAMING_SNAKE_CASE						)["""positions"""]
   _snake_case				:						Union[str, Any]								=    torch.tensor([2.5_828, 0.7_993, -10.9_334], dtype=torch.floataa						)
   self.assertTrue(torch.allclose(position_outputs[0, 0, 0, 0], _SCREAMING_SNAKE_CASE, atol=1E-4						)						)










from pathlib import Path

import fire
def 		lowercase__  (				_UpperCamelCase       ,							_UpperCamelCase       ,							_UpperCamelCase) ->			Optional[int]:
      """simple docstring"""

      UpperCamelCase					       =  Path(_UpperCamelCase)
      UpperCamelCase					       =  Path(_UpperCamelCase)
      dest_dir.mkdir(exist_ok=_UpperCamelCase)
      for path in src_dir.iterdir():
            UpperCamelCase					       =  [x.rstrip() for x in list(path.open().readlines())][:n]
            UpperCamelCase					       =  dest_dir.joinpath(path.name)
            print(_UpperCamelCase)
            dest_path.open('w').write('\n'.join(_UpperCamelCase))


if __name__ == "__main__":
       fire.Fire(minify)



