






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




							def __init__(							self:				List[str]			,							UpperCamelCase__:				Any			,							UpperCamelCase__:				Union[str, Any]=13			,							UpperCamelCase__:				List[str]=7			,							UpperCamelCase__:				Optional[Any]=False			,							UpperCamelCase__:				Dict=True			,							UpperCamelCase__:				Tuple=False			,							UpperCamelCase__:				Optional[Any]=False			,							UpperCamelCase__:				List[Any]=19			,							UpperCamelCase__:				str=32			,							UpperCamelCase__:				Tuple=5			,							UpperCamelCase__:				Any=4			,							UpperCamelCase__:				Dict=37			,							UpperCamelCase__:				Dict="gelu"			,							UpperCamelCase__:				Any=0.1			,							UpperCamelCase__:				str=0.1			,							UpperCamelCase__:				Optional[int]=512			,							UpperCamelCase__:				str=16			,							UpperCamelCase__:				List[str]=2			,							UpperCamelCase__:				List[Any]=0.02			,							UpperCamelCase__:				str=3			,							UpperCamelCase__:				List[str]=4			,							UpperCamelCase__:				Union[str, Any]=None			,							):
														lowerCamelCase__					:	Any         =       parent
														lowerCamelCase__					:	str         =       batch_size
														lowerCamelCase__					:	Optional[Any]         =       seq_length
														lowerCamelCase__					:	List[Any]         =       is_training
														lowerCamelCase__					:	Optional[int]         =       use_input_mask
														lowerCamelCase__					:	List[str]         =       use_token_type_ids
														lowerCamelCase__					:	List[Any]         =       use_labels
														lowerCamelCase__					:	List[str]         =       vocab_size
														lowerCamelCase__					:	str         =       hidden_size
														lowerCamelCase__					:	str         =       num_hidden_layers
														lowerCamelCase__					:	Optional[int]         =       num_attention_heads
														lowerCamelCase__					:	Any         =       intermediate_size
														lowerCamelCase__					:	Any         =       hidden_act
														lowerCamelCase__					:	Optional[Any]         =       hidden_dropout_prob
														lowerCamelCase__					:	Union[str, Any]         =       attention_probs_dropout_prob
														lowerCamelCase__					:	Tuple         =       max_position_embeddings
														lowerCamelCase__					:	int         =       type_vocab_size
														lowerCamelCase__					:	Dict         =       type_sequence_label_size
														lowerCamelCase__					:	int         =       initializer_range
														lowerCamelCase__					:	List[Any]         =       num_labels
														lowerCamelCase__					:	List[Any]         =       num_choices
														lowerCamelCase__					:	Any         =       scope




							def 		lowerCamelCase_				(							self:				Optional[int]     ):
														lowerCamelCase__					:	int         =       ids_tensor([self.batch_size, self.seq_length]			,							self.vocab_size     )

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

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

														lowerCamelCase__					:	Any         =       self.get_config()

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




							def 		lowerCamelCase_				(							self:				Optional[int]     ):
														lowerCamelCase__					:	Optional[Any]         =       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=UpperCamelCase__			,							esmfold_config={"""trunk""": {"""num_blocks""": 2}, """fp16_esm""": False}			,							)
														return config




							def 		lowerCamelCase_				(							self:				str			,							UpperCamelCase__:				Optional[Any]			,							UpperCamelCase__:				int			,							UpperCamelCase__:				Any			,							UpperCamelCase__:				Union[str, Any]			,							UpperCamelCase__:				str			,							UpperCamelCase__:				Any     ):
														lowerCamelCase__					:	Dict         =       EsmForProteinFolding(config=UpperCamelCase__     ).float()
														model.to(UpperCamelCase__     )
														model.eval()
														lowerCamelCase__					:	Optional[int]         =       model(UpperCamelCase__			,							attention_mask=UpperCamelCase__     )
														lowerCamelCase__					:	Optional[int]         =       model(UpperCamelCase__     )
														lowerCamelCase__					:	Dict         =       model(UpperCamelCase__     )

														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 		lowerCamelCase_				(							self:				str     ):
														lowerCamelCase__					:	int         =       self.prepare_config_and_inputs()
														(
														    (
														    lowerCamelCase__
														)  ,		(
														    lowerCamelCase__
														)  ,		(
														    lowerCamelCase__
														)  ,		(
														    lowerCamelCase__
														)  ,		(
														    lowerCamelCase__
														)  ,		(
														    lowerCamelCase__
														)  ,		
														)					:	int         =       config_and_inputs
														lowerCamelCase__					:	str         =       {"""input_ids""": input_ids, """attention_mask""": input_mask}
														return config, inputs_dict



@require_torch
class _lowercase	(				_lowercase				,      _lowercase				,      unittest.TestCase		):
							a				      =       False

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




							def 		lowerCamelCase_				(							self:				Union[str, Any]     ):
														lowerCamelCase__					:	Optional[Any]         =       EsmFoldModelTester(self     )
														lowerCamelCase__					:	Optional[Any]         =       ConfigTester(self			,							config_class=UpperCamelCase__			,							hidden_size=37     )




							def 		lowerCamelCase_				(							self:				Tuple     ):
														self.config_tester.run_common_tests()




							def 		lowerCamelCase_				(							self:				Tuple     ):
														lowerCamelCase__					:	Union[str, Any]         =       self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_model(*UpperCamelCase__     )




							@unittest.skip("""Does not support attention outputs"""     )
							def 		lowerCamelCase_				(							self:				List[Any]     ):
														pass




							@unittest.skip
							def 		lowerCamelCase_				(							self:				int     ):
														pass




							@unittest.skip("""Esm does not support embedding resizing"""     )
							def 		lowerCamelCase_				(							self:				Optional[Any]     ):
														pass




							@unittest.skip("""Esm does not support embedding resizing"""     )
							def 		lowerCamelCase_				(							self:				str     ):
														pass




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




							@unittest.skip("""ESMFold does not support head pruning."""     )
							def 		lowerCamelCase_				(							self:				int     ):
														pass




							@unittest.skip("""ESMFold does not support head pruning."""     )
							def 		lowerCamelCase_				(							self:				Optional[Any]     ):
														pass




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




							@unittest.skip("""ESMFold does not support head pruning."""     )
							def 		lowerCamelCase_				(							self:				Optional[int]     ):
														pass




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




							@unittest.skip("""ESMFold does not output hidden states in the normal way."""     )
							def 		lowerCamelCase_				(							self:				Optional[int]     ):
														pass




							@unittest.skip("""ESMfold does not output hidden states in the normal way."""     )
							def 		lowerCamelCase_				(							self:				Union[str, Any]     ):
														pass




							@unittest.skip("""ESMFold only has one output format."""     )
							def 		lowerCamelCase_				(							self:				Dict     ):
														pass




							@unittest.skip("""This test doesn't work for ESMFold and doesn't test core functionality"""     )
							def 		lowerCamelCase_				(							self:				Union[str, Any]     ):
														pass




							@unittest.skip("""ESMFold does not support input chunking."""     )
							def 		lowerCamelCase_				(							self:				Any     ):
														pass




							@unittest.skip("""ESMFold doesn't respect you and it certainly doesn't respect your initialization arguments."""     )
							def 		lowerCamelCase_				(							self:				Optional[int]     ):
														pass




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




							@unittest.skip("""ESMFold doesn't support torchscript compilation."""     )
							def 		lowerCamelCase_				(							self:				str     ):
														pass




							@unittest.skip("""ESMFold doesn't support torchscript compilation."""     )
							def 		lowerCamelCase_				(							self:				List[Any]     ):
														pass




							@unittest.skip("""ESMFold doesn't support data parallel."""     )
							def 		lowerCamelCase_				(							self:				Tuple     ):
														pass




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



@require_torch
class _lowercase	(				_lowercase		):




							@slow
							def 		lowerCamelCase_				(							self:				str     ):
														lowerCamelCase__					:	List[Any]         =       EsmForProteinFolding.from_pretrained("""facebook/esmfold_v1"""     ).float()
														model.eval()
														lowerCamelCase__					:	Optional[int]         =       torch.tensor([[0, 6, 4, 13, 5, 4, 16, 12, 11, 7, 2]]     )
														lowerCamelCase__					:	Any         =       model(UpperCamelCase__     )["""positions"""]
														lowerCamelCase__					:	Dict         =       torch.tensor([2.5_828, 0.7_993, -10.9_334]			,							dtype=torch.floataa     )
														self.assertTrue(torch.allclose(position_outputs[0, 0, 0, 0]			,							UpperCamelCase__			,							atol=1e-4     )     )




from argparse import ArgumentParser

from datasets.commands.convert import ConvertCommand
from datasets.commands.dummy_data import DummyDataCommand
from datasets.commands.env import EnvironmentCommand
from datasets.commands.run_beam import RunBeamCommand
from datasets.commands.test import TestCommand
from datasets.utils.logging import set_verbosity_info
def 						_snake_case(    SCREAMING_SNAKE_CASE__			:	Tuple      )							->      Tuple:





    '''simple docstring'''






    return {key.lstrip('-'      ): value for key, value in zip(unknown_args[::2]    ,			unknown_args[1::2]      )}
def 						_snake_case(    )							->      Dict:





    '''simple docstring'''






    A__          =   ArgumentParser(
        'HuggingFace Datasets CLI tool'    ,			usage='datasets-cli <command> [<args>]'    ,			allow_abbrev=SCREAMING_SNAKE_CASE__      )
    A__          =   parser.add_subparsers(help='datasets-cli command helpers'      )
    set_verbosity_info()

    # Register commands
    ConvertCommand.register_subcommand(SCREAMING_SNAKE_CASE__      )
    EnvironmentCommand.register_subcommand(SCREAMING_SNAKE_CASE__      )
    TestCommand.register_subcommand(SCREAMING_SNAKE_CASE__      )
    RunBeamCommand.register_subcommand(SCREAMING_SNAKE_CASE__      )
    DummyDataCommand.register_subcommand(SCREAMING_SNAKE_CASE__      )

    # Parse args
    A__      ,						A__          =   parser.parse_known_args()
    if not hasattr(SCREAMING_SNAKE_CASE__    ,			'func'      ):
        parser.print_help()
        exit(1      )
    A__          =   parse_unknown_args(SCREAMING_SNAKE_CASE__      )

    # Run
    A__          =   args.func(SCREAMING_SNAKE_CASE__    ,			**SCREAMING_SNAKE_CASE__      )
    service.run()


if __name__ == "__main__":
     main()

