





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       ,							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       ,							):
       '''simple docstring'''




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





      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       UpperCamelCase	:					List[Any]       	=   ids_tensor([self.batch_size, self.seq_length]       ,							self.vocab_size   )

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

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

       UpperCamelCase	:					Union[str, Any]       	=   self.get_config()

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





      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       UpperCamelCase	:					Optional[int]       	=   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        __UpperCamelCase( self       ,							A_       ,							A_       ,							A_       ,							A_       ,							A_       ,							A_   ):
       '''simple docstring'''




       UpperCamelCase	:					Optional[Any]       	=   EsmForProteinFolding(config=A_   ).float()
       model.to(A_   )
       model.eval()
       UpperCamelCase	:					Optional[int]       	=   model(A_       ,							attention_mask=A_   )
       UpperCamelCase	:					Optional[int]       	=   model(A_   )
       UpperCamelCase	:					Tuple       	=   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        __UpperCamelCase( self   ):
       '''simple docstring'''




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



@require_torch
class 					A__   (       __snake_case       ,   __snake_case       ,   unittest.TestCase			):
      _UpperCAmelCase	:int						    =   False

      _UpperCAmelCase	:Tuple						    =   (EsmForProteinFolding,) if is_torch_available() else ()
      _UpperCAmelCase	:Optional[int]						    =   ()
      _UpperCAmelCase	:Optional[int]						    =   {} if is_torch_available() else {}
      _UpperCAmelCase	:str						    =   False





      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       UpperCamelCase	:					str       	=   EsmFoldModelTester(self   )
       UpperCamelCase	:					Tuple       	=   ConfigTester(self       ,							config_class=A_       ,							hidden_size=37   )





      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       self.config_tester.run_common_tests()





      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       UpperCamelCase	:					Optional[Any]       	=   self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*A_   )





      @unittest.skip("Does not support attention outputs"   )
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass





      @unittest.skip
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass





      @unittest.skip("Esm does not support embedding resizing"   )
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass





      @unittest.skip("Esm does not support embedding resizing"   )
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass





      @unittest.skip("ESMFold does not support passing input embeds!"   )
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass





      @unittest.skip("ESMFold does not support head pruning."   )
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass





      @unittest.skip("ESMFold does not support head pruning."   )
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass





      @unittest.skip("ESMFold does not support head pruning."   )
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass





      @unittest.skip("ESMFold does not support head pruning."   )
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass





      @unittest.skip("ESMFold does not support head pruning."   )
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass





      @unittest.skip("ESMFold does not output hidden states in the normal way."   )
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass





      @unittest.skip("ESMfold does not output hidden states in the normal way."   )
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass





      @unittest.skip("ESMFold only has one output format."   )
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass





      @unittest.skip("This test doesn't work for ESMFold and doesn't test core functionality"   )
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass





      @unittest.skip("ESMFold does not support input chunking."   )
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass





      @unittest.skip("ESMFold doesn't respect you and it certainly doesn't respect your initialization arguments."   )
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass





      @unittest.skip("ESMFold doesn't support torchscript compilation."   )
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass





      @unittest.skip("ESMFold doesn't support torchscript compilation."   )
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass





      @unittest.skip("ESMFold doesn't support torchscript compilation."   )
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass





      @unittest.skip("ESMFold doesn't support data parallel."   )
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass





      @unittest.skip("Will be fixed soon by reducing the size of the model used for common tests."   )
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       pass



@require_torch
class 					A__   (       __snake_case			):





      @slow
      def        __UpperCamelCase( self   ):
       '''simple docstring'''




       UpperCamelCase	:					List[Any]       	=   EsmForProteinFolding.from_pretrained("facebook/esmfold_v1"   ).float()
       model.eval()
       UpperCamelCase	:					List[str]       	=   torch.tensor([[0, 6, 4, 13, 5, 4, 16, 12, 11, 7, 2]]   )
       UpperCamelCase	:					List[str]       	=   model(A_   )["positions"]
       UpperCamelCase	:					Union[str, Any]       	=   torch.tensor([2.58_28, 0.79_93, -10.93_34]       ,							dtype=torch.floataa   )
       self.assertTrue(torch.allclose(position_outputs[0, 0, 0, 0]       ,							A_       ,							atol=1e-4   )   )







import inspect
import re

from transformers.utils import direct_transformers_import


# All paths are set with the intent you should run this script from the root of the repo with the command
# python utils/check_config_docstrings.py
__lowerCamelCase       :     str   =     """src/transformers"""


# This is to make sure the transformers module imported is the one in the repo.
__lowerCamelCase       :     Tuple   =     direct_transformers_import(PATH_TO_TRANSFORMERS)

__lowerCamelCase       :     List[str]   =     transformers.models.auto.configuration_auto.CONFIG_MAPPING

# Regex pattern used to find the checkpoint mentioned in the docstring of `config_class`.
# For example, `[bert-base-uncased](https://huggingface.co/bert-base-uncased)`
__lowerCamelCase       :     Optional[Any]   =     re.compile(r"""\[(.+?)\]\((https://huggingface\.co/.+?)\)""")


__lowerCamelCase       :     List[str]   =     {
    """DecisionTransformerConfig""",
    """EncoderDecoderConfig""",
    """MusicgenConfig""",
    """RagConfig""",
    """SpeechEncoderDecoderConfig""",
    """TimmBackboneConfig""",
    """VisionEncoderDecoderConfig""",
    """VisionTextDualEncoderConfig""",
    """LlamaConfig""",
}



def 		A_				(     _lowerCAmelCase     )						-> List[str]:
 UpperCamelCase	:					Optional[Any]       	=   None

 # source code of `config_class`
 UpperCamelCase	:					Tuple       	=   inspect.getsource(_lowerCAmelCase     )
 UpperCamelCase	:					Optional[Any]       	=   _re_checkpoint.findall(_lowerCAmelCase     )

 # Each `checkpoint` is a tuple of a checkpoint name and a checkpoint link.
 # For example, `('bert-base-uncased', 'https://huggingface.co/bert-base-uncased')`
 for ckpt_name, ckpt_link in checkpoints:
  # allow the link to end with `/`
  if ckpt_link.endswith("/"     ):
   UpperCamelCase	:					Dict       	=   ckpt_link[:-1]

  # verify the checkpoint name corresponds to the checkpoint link
  UpperCamelCase	:					Any       	=   F"""https://huggingface.co/{ckpt_name}"""
  if ckpt_link == ckpt_link_from_name:
   UpperCamelCase	:					List[Any]       	=   ckpt_name
   break

 return checkpoint



def 		A_				(     )						-> List[str]:
 UpperCamelCase	:					Optional[int]       	=   []

 for config_class in list(CONFIG_MAPPING.values()     ):
  # Skip deprecated models
  if "models.deprecated" in config_class.__module__:
   continue
  UpperCamelCase	:					Union[str, Any]       	=   get_checkpoint_from_config_class(_lowerCAmelCase     )

  UpperCamelCase	:					Optional[int]       	=   config_class.__name__
  if checkpoint is None and name not in CONFIG_CLASSES_TO_IGNORE_FOR_DOCSTRING_CHECKPOINT_CHECK:
   configs_without_checkpoint.append(_lowerCAmelCase     )

 if len(_lowerCAmelCase     ) > 0:
  UpperCamelCase	:					Any       	=   "\n".join(sorted(_lowerCAmelCase     )     )
  raise ValueError(F"""The following configurations don't contain any valid checkpoint:\n{message}"""     )


if __name__ == "__main__":
    check_config_docstrings_have_checkpoints()
