
"""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__						:
   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.0_2	,    _a=3	,    _a=4	,    _a=None	,    ):
          lowercase    :				Dict       		=							parent
          lowercase    :				List[Any]       		=							batch_size
          lowercase    :				Any       		=							seq_length
          lowercase    :				Optional[int]       		=							is_training
          lowercase    :				Dict       		=							use_input_mask
          lowercase    :				Dict       		=							use_token_type_ids
          lowercase    :				int       		=							use_labels
          lowercase    :				List[Any]       		=							vocab_size
          lowercase    :				Optional[int]       		=							hidden_size
          lowercase    :				List[Any]       		=							num_hidden_layers
          lowercase    :				Optional[int]       		=							num_attention_heads
          lowercase    :				Optional[int]       		=							intermediate_size
          lowercase    :				Dict       		=							hidden_act
          lowercase    :				Any       		=							hidden_dropout_prob
          lowercase    :				int       		=							attention_probs_dropout_prob
          lowercase    :				Any       		=							max_position_embeddings
          lowercase    :				str       		=							type_vocab_size
          lowercase    :				Optional[int]       		=							type_sequence_label_size
          lowercase    :				Any       		=							initializer_range
          lowercase    :				Dict       		=							num_labels
          lowercase    :				List[str]       		=							num_choices
          lowercase    :				List[str]       		=							scope
   def 			__magic_name__			(			self				):
          lowercase    :				Any       		=							ids_tensor([self.batch_size, self.seq_length]	,    self.vocab_size				)

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

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

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

          return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels
   def 			__magic_name__			(			self				):
          lowercase    :				List[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=_a	,    esmfold_config={"trunk": {"num_blocks": 2}, "fp16_esm": False}	,    )
          return config
   def 			__magic_name__			(			self	,    _a	,    _a	,    _a	,    _a	,    _a	,    _a				):
          lowercase    :				Optional[int]       		=							EsmForProteinFolding(config=_a				).float()
          model.to(_a				)
          model.eval()
          lowercase    :				Any       		=							model(_a	,    attention_mask=_a				)
          lowercase    :				Union[str, Any]       		=							model(_a				)
          lowercase    :				int       		=							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 			__magic_name__			(			self				):
          lowercase    :				Union[str, Any]       		=							self.prepare_config_and_inputs()
          (
              (
              lowercase
          )		,    (
              lowercase
          )		,    (
              lowercase
          )		,    (
              lowercase
          )		,    (
              lowercase
          )		,    (
              lowercase
          )		,    
          )    :				List[str]       		=							config_and_inputs
          lowercase    :				List[Any]       		=							{"input_ids": input_ids, "attention_mask": input_mask}
          return config, inputs_dict


@require_torch
class 		a__						(      a_,			a_,			unittest.TestCase						):
   __lowerCAmelCase            =				False

   __lowerCAmelCase            =				(EsmForProteinFolding,) if is_torch_available() else ()
   __lowerCAmelCase            =				()
   __lowerCAmelCase            =				{} if is_torch_available() else {}
   __lowerCAmelCase            =				False
   def 			__magic_name__			(			self				):
          lowercase    :				Dict       		=							EsmFoldModelTester(self				)
          lowercase    :				List[Any]       		=							ConfigTester(self	,    config_class=_a	,    hidden_size=37				)
   def 			__magic_name__			(			self				):
          self.config_tester.run_common_tests()
   def 			__magic_name__			(			self				):
          lowercase    :				Tuple       		=							self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_model(*_a				)
   @unittest.skip("Does not support attention outputs"				)
   def 			__magic_name__			(			self				):
          pass
   @unittest.skip
   def 			__magic_name__			(			self				):
          pass
   @unittest.skip("Esm does not support embedding resizing"				)
   def 			__magic_name__			(			self				):
          pass
   @unittest.skip("Esm does not support embedding resizing"				)
   def 			__magic_name__			(			self				):
          pass
   @unittest.skip("ESMFold does not support passing input embeds!"				)
   def 			__magic_name__			(			self				):
          pass
   @unittest.skip("ESMFold does not support head pruning."				)
   def 			__magic_name__			(			self				):
          pass
   @unittest.skip("ESMFold does not support head pruning."				)
   def 			__magic_name__			(			self				):
          pass
   @unittest.skip("ESMFold does not support head pruning."				)
   def 			__magic_name__			(			self				):
          pass
   @unittest.skip("ESMFold does not support head pruning."				)
   def 			__magic_name__			(			self				):
          pass
   @unittest.skip("ESMFold does not support head pruning."				)
   def 			__magic_name__			(			self				):
          pass
   @unittest.skip("ESMFold does not output hidden states in the normal way."				)
   def 			__magic_name__			(			self				):
          pass
   @unittest.skip("ESMfold does not output hidden states in the normal way."				)
   def 			__magic_name__			(			self				):
          pass
   @unittest.skip("ESMFold only has one output format."				)
   def 			__magic_name__			(			self				):
          pass
   @unittest.skip("This test doesn't work for ESMFold and doesn't test core functionality"				)
   def 			__magic_name__			(			self				):
          pass
   @unittest.skip("ESMFold does not support input chunking."				)
   def 			__magic_name__			(			self				):
          pass
   @unittest.skip("ESMFold doesn't respect you and it certainly doesn't respect your initialization arguments."				)
   def 			__magic_name__			(			self				):
          pass
   @unittest.skip("ESMFold doesn't support torchscript compilation."				)
   def 			__magic_name__			(			self				):
          pass
   @unittest.skip("ESMFold doesn't support torchscript compilation."				)
   def 			__magic_name__			(			self				):
          pass
   @unittest.skip("ESMFold doesn't support torchscript compilation."				)
   def 			__magic_name__			(			self				):
          pass
   @unittest.skip("ESMFold doesn't support data parallel."				)
   def 			__magic_name__			(			self				):
          pass

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


@require_torch
class 		a__						(      a_						):
   @slow
   def 			__magic_name__			(			self				):
          lowercase    :				Dict       		=							EsmForProteinFolding.from_pretrained("facebook/esmfold_v1"				).float()
          model.eval()
          lowercase    :				List[str]       		=							torch.tensor([[0, 6, 4, 13, 5, 4, 16, 12, 11, 7, 2]]				)
          lowercase    :				List[str]       		=							model(_a				)["positions"]
          lowercase    :				Any       		=							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]	,    _a	,    atol=1E-4				)				)




"""simple docstring"""




from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_tokenizers_available,
    is_torch_available,
)


_A			:       Optional[int]   		=       {
    """configuration_llama""": ["""LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LlamaConfig"""],
}

try:
   if not is_sentencepiece_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _A			:       Union[str, Any]   		=       ["""LlamaTokenizer"""]

try:
   if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _A			:       Dict   		=       ["""LlamaTokenizerFast"""]

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _A			:       int   		=       [
       """LlamaForCausalLM""",
       """LlamaModel""",
       """LlamaPreTrainedModel""",
       """LlamaForSequenceClassification""",
   ]


if TYPE_CHECKING:
   from .configuration_llama import LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP, LlamaConfig

   try:
      if not is_sentencepiece_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_llama import LlamaTokenizer

   try:
      if not is_tokenizers_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_llama_fast import LlamaTokenizerFast

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_llama import LlamaForCausalLM, LlamaForSequenceClassification, LlamaModel, LlamaPreTrainedModel


else:
   import sys

   _A			:       str   		=       _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)


