

'''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 ,			a_ ,			a_=1_3 ,			a_=7 ,			a_=False ,			a_=True ,			a_=False ,			a_=False ,			a_=1_9 ,			a_=3_2 ,			a_=5 ,			a_=4 ,			a_=3_7 ,			a_="gelu" ,			a_=0.1 ,			a_=0.1 ,			a_=5_1_2 ,			a_=1_6 ,			a_=2 ,			a_=0.02 ,			a_=3 ,			a_=4 ,			a_=None ,			)				->					Any:


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


    """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     snake_case_      (  self  )				->					Any:


    """simple docstring"""
    UpperCAmelCase    				=						EsmConfig(
        vocab_size=3_3 ,			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     snake_case_      (  self ,			a_ ,			a_ ,			a_ ,			a_ ,			a_ ,			a_  )				->					Optional[Any]:


    """simple docstring"""
    UpperCAmelCase    				=						EsmForProteinFolding(config=a_  ).float()
    model.to(a_  )
    model.eval()
    UpperCAmelCase    				=						model(a_ ,			attention_mask=a_  )
    UpperCAmelCase    				=						model(a_  )
    UpperCAmelCase    				=						model(a_  )

    self.parent.assertEqual(result.positions.shape ,			(8, self.batch_size, self.seq_length, 1_4, 3)  )
    self.parent.assertEqual(result.angles.shape ,			(8, self.batch_size, self.seq_length, 7, 2)  )





  def     snake_case_      (  self  )				->					List[str]:


    """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 							lowercase_						(		a			,							a			,							unittest.TestCase			):

  '''simple docstring'''





  __lowerCAmelCase       :			Optional[int]     	= False

  __lowerCAmelCase       :			Dict     	= (EsmForProteinFolding,) if is_torch_available() else ()
  __lowerCAmelCase       :			int     	= ()
  __lowerCAmelCase       :			Optional[Any]     	= {} if is_torch_available() else {}
  __lowerCAmelCase       :			Optional[Any]     	= False
  def     snake_case_      (  self  )				->					Dict:


    """simple docstring"""
    UpperCAmelCase    				=						EsmFoldModelTester(self  )
    UpperCAmelCase    				=						ConfigTester(self ,			config_class=a_ ,			hidden_size=3_7  )
  def     snake_case_      (  self  )				->					str:


    """simple docstring"""
    self.config_tester.run_common_tests()
  def     snake_case_      (  self  )				->					List[Any]:


    """simple docstring"""
    UpperCAmelCase    				=						self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_model(*a_  )
  @unittest.skip('Does not support attention outputs'  )
  def     snake_case_      (  self  )				->					Optional[int]:


    """simple docstring"""
    pass
  @unittest.skip
  def     snake_case_      (  self  )				->					str:


    """simple docstring"""
    pass
  @unittest.skip('Esm does not support embedding resizing'  )
  def     snake_case_      (  self  )				->					Tuple:


    """simple docstring"""
    pass
  @unittest.skip('Esm does not support embedding resizing'  )
  def     snake_case_      (  self  )				->					Union[str, Any]:


    """simple docstring"""
    pass
  @unittest.skip('ESMFold does not support passing input embeds!'  )
  def     snake_case_      (  self  )				->					Optional[Any]:


    """simple docstring"""
    pass
  @unittest.skip('ESMFold does not support head pruning.'  )
  def     snake_case_      (  self  )				->					str:


    """simple docstring"""
    pass
  @unittest.skip('ESMFold does not support head pruning.'  )
  def     snake_case_      (  self  )				->					List[str]:


    """simple docstring"""
    pass
  @unittest.skip('ESMFold does not support head pruning.'  )
  def     snake_case_      (  self  )				->					List[Any]:


    """simple docstring"""
    pass
  @unittest.skip('ESMFold does not support head pruning.'  )
  def     snake_case_      (  self  )				->					Any:


    """simple docstring"""
    pass
  @unittest.skip('ESMFold does not support head pruning.'  )
  def     snake_case_      (  self  )				->					Tuple:


    """simple docstring"""
    pass
  @unittest.skip('ESMFold does not output hidden states in the normal way.'  )
  def     snake_case_      (  self  )				->					List[str]:


    """simple docstring"""
    pass
  @unittest.skip('ESMfold does not output hidden states in the normal way.'  )
  def     snake_case_      (  self  )				->					Dict:


    """simple docstring"""
    pass
  @unittest.skip('ESMFold only has one output format.'  )
  def     snake_case_      (  self  )				->					Optional[int]:


    """simple docstring"""
    pass
  @unittest.skip('This test doesn\'t work for ESMFold and doesn\'t test core functionality'  )
  def     snake_case_      (  self  )				->					Any:


    """simple docstring"""
    pass
  @unittest.skip('ESMFold does not support input chunking.'  )
  def     snake_case_      (  self  )				->					List[str]:


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


    """simple docstring"""
    pass
  @unittest.skip('ESMFold doesn\'t support torchscript compilation.'  )
  def     snake_case_      (  self  )				->					List[Any]:


    """simple docstring"""
    pass
  @unittest.skip('ESMFold doesn\'t support torchscript compilation.'  )
  def     snake_case_      (  self  )				->					List[Any]:


    """simple docstring"""
    pass
  @unittest.skip('ESMFold doesn\'t support torchscript compilation.'  )
  def     snake_case_      (  self  )				->					Optional[int]:


    """simple docstring"""
    pass
  @unittest.skip('ESMFold doesn\'t support data parallel.'  )
  def     snake_case_      (  self  )				->					List[str]:


    """simple docstring"""
    pass





  @unittest.skip('Will be fixed soon by reducing the size of the model used for common tests.'  )
  def     snake_case_      (  self  )				->					Any:


    """simple docstring"""
    pass




@require_torch
class 							lowercase_						(		a			):

  '''simple docstring'''





  @slow
  def     snake_case_      (  self  )				->					Optional[Any]:


    """simple docstring"""
    UpperCAmelCase    				=						EsmForProteinFolding.from_pretrained('facebook/esmfold_v1'  ).float()
    model.eval()
    UpperCAmelCase    				=						torch.tensor([[0, 6, 4, 1_3, 5, 4, 1_6, 1_2, 1_1, 7, 2]]  )
    UpperCAmelCase    				=						model(a_  )['positions']
    UpperCAmelCase    				=						torch.tensor([2.5828, 0.7993, -10.9334] ,			dtype=torch.floataa  )
    self.assertTrue(torch.allclose(position_outputs[0, 0, 0, 0] ,			a_ ,			atol=1E-4  )  )





'''simple docstring'''




import qiskit


def    lowerCamelCase__		(    SCREAMING_SNAKE_CASE   : int							, SCREAMING_SNAKE_CASE   : int    ):
  UpperCAmelCase    				=						qiskit.Aer.get_backend('aer_simulator'    )

  # Create a Quantum Circuit acting on the q register
  UpperCAmelCase    				=						qiskit.QuantumCircuit(SCREAMING_SNAKE_CASE							, SCREAMING_SNAKE_CASE    )

  # Map the quantum measurement to the classical bits
  circuit.measure([0]							, [0]    )

  # Execute the circuit on the simulator
  UpperCAmelCase    				=						qiskit.execute(SCREAMING_SNAKE_CASE							, SCREAMING_SNAKE_CASE							, shots=1000    )

  # Return the histogram data of the results of the experiment.
  return job.result().get_counts(SCREAMING_SNAKE_CASE    )


if __name__ == "__main__":
  print(F'''Total count for various states are: {single_qubit_measure(1, 1)}''')


