

'''simple docstring'''





import unittest

from parameterized import parameterized

from transformers import OpenLlamaConfig, is_torch_available, set_seed
from transformers.testing_utils import require_torch, torch_device

from ...generation.test_utils import GenerationTesterMixin
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 import OpenLlamaForCausalLM, OpenLlamaForSequenceClassification, OpenLlamaModel





class 		__SCREAMING_SNAKE_CASE							:







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







				def  lowerCamelCase_	(       self     :		Optional[int]   ):
										'''simple docstring'''
										lowercase :							List[str]    		=ids_tensor([self.batch_size, self.seq_length]		,					self.vocab_size   )

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

										lowercase :							Union[str, Any]    		=None
										if self.use_token_type_ids:
																lowercase :							List[str]    		=ids_tensor([self.batch_size, self.seq_length]		,					self.type_vocab_size   )

										lowercase :							str    		=None
										lowercase :							int    		=None
										lowercase :							Any    		=None
										if self.use_labels:
																lowercase :							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 :							List[str]    		=ids_tensor([self.batch_size]		,					self.num_choices   )

										lowercase :							List[str]    		=self.get_config()

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







				def  lowerCamelCase_	(       self     :		Any   ):
										'''simple docstring'''
										return OpenLlamaConfig(
										    vocab_size=self.vocab_size		,					hidden_size=self.hidden_size		,					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		,					is_decoder=UpperCAmelCase__		,					initializer_range=self.initializer_range		,					use_stable_embedding=UpperCAmelCase__		,					)







				def  lowerCamelCase_	(       self     :		Dict		,					UpperCAmelCase__     :		Optional[int]		,					UpperCAmelCase__     :		Tuple		,					UpperCAmelCase__     :		Optional[Any]		,					UpperCAmelCase__     :		Tuple		,					UpperCAmelCase__     :		str		,					UpperCAmelCase__     :		str		,					UpperCAmelCase__     :		List[str]   ):
										'''simple docstring'''
										lowercase :							Union[str, Any]    		=OpenLlamaModel(config=UpperCAmelCase__   )
										model.to(UpperCAmelCase__   )
										model.eval()
										lowercase :							str    		=model(UpperCAmelCase__		,					attention_mask=UpperCAmelCase__   )
										lowercase :							Tuple    		=model(UpperCAmelCase__   )
										self.parent.assertEqual(result.last_hidden_state.shape		,					(self.batch_size, self.seq_length, self.hidden_size)   )







				def  lowerCamelCase_	(       self     :		Optional[Any]		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		Optional[int]		,					UpperCAmelCase__     :		Dict		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		str		,					UpperCAmelCase__     :		Any		,					UpperCAmelCase__     :		Tuple		,					UpperCAmelCase__     :		Any		,					):
										'''simple docstring'''
										lowercase :							Optional[Any]    		=True
										lowercase :							Optional[Any]    		=OpenLlamaModel(UpperCAmelCase__   )
										model.to(UpperCAmelCase__   )
										model.eval()
										lowercase :							List[str]    		=model(
										    UpperCAmelCase__		,					attention_mask=UpperCAmelCase__		,					encoder_hidden_states=UpperCAmelCase__		,					encoder_attention_mask=UpperCAmelCase__		,					)
										lowercase :							int    		=model(
										    UpperCAmelCase__		,					attention_mask=UpperCAmelCase__		,					encoder_hidden_states=UpperCAmelCase__		,					)
										lowercase :							Optional[Any]    		=model(UpperCAmelCase__		,					attention_mask=UpperCAmelCase__   )
										self.parent.assertEqual(result.last_hidden_state.shape		,					(self.batch_size, self.seq_length, self.hidden_size)   )







				def  lowerCamelCase_	(       self     :		str		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		str		,					UpperCAmelCase__     :		Tuple		,					UpperCAmelCase__     :		str		,					UpperCAmelCase__     :		Optional[Any]		,					UpperCAmelCase__     :		Dict		,					UpperCAmelCase__     :		Union[str, Any]		,					UpperCAmelCase__     :		Any		,					UpperCAmelCase__     :		Any		,					):
										'''simple docstring'''
										lowercase :							List[str]    		=OpenLlamaForCausalLM(config=UpperCAmelCase__   )
										model.to(UpperCAmelCase__   )
										model.eval()
										lowercase :							Union[str, Any]    		=model(UpperCAmelCase__		,					attention_mask=UpperCAmelCase__		,					labels=UpperCAmelCase__   )
										self.parent.assertEqual(result.logits.shape		,					(self.batch_size, self.seq_length, self.vocab_size)   )







				def  lowerCamelCase_	(       self     :		str		,					UpperCAmelCase__     :		Dict		,					UpperCAmelCase__     :		Any		,					UpperCAmelCase__     :		Optional[Any]		,					UpperCAmelCase__     :		Any		,					UpperCAmelCase__     :		Tuple		,					UpperCAmelCase__     :		Optional[int]		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		Any		,					UpperCAmelCase__     :		List[Any]		,					):
										'''simple docstring'''
										lowercase :							int    		=True
										lowercase :							List[str]    		=True
										lowercase :							Tuple    		=OpenLlamaForCausalLM(config=UpperCAmelCase__   )
										model.to(UpperCAmelCase__   )
										model.eval()

										# first forward pass
										lowercase :							Optional[int]    		=model(
										    UpperCAmelCase__		,					attention_mask=UpperCAmelCase__		,					encoder_hidden_states=UpperCAmelCase__		,					encoder_attention_mask=UpperCAmelCase__		,					use_cache=UpperCAmelCase__		,					)
										lowercase :							Union[str, Any]    		=outputs.past_key_values

										# create hypothetical multiple next token and extent to next_input_ids
										lowercase :							Any    		=ids_tensor((self.batch_size, 3)		,					config.vocab_size   )
										lowercase :							Tuple    		=ids_tensor((self.batch_size, 3)		,					vocab_size=2   )

										# append to next input_ids and
										lowercase :							Any    		=torch.cat([input_ids, next_tokens]		,					dim=-1   )
										lowercase :							int    		=torch.cat([input_mask, next_mask]		,					dim=-1   )

										lowercase :							Dict    		=model(
										    UpperCAmelCase__		,					attention_mask=UpperCAmelCase__		,					encoder_hidden_states=UpperCAmelCase__		,					encoder_attention_mask=UpperCAmelCase__		,					output_hidden_states=UpperCAmelCase__		,					)['''hidden_states'''][0]
										lowercase :							Optional[int]    		=model(
										    UpperCAmelCase__		,					attention_mask=UpperCAmelCase__		,					encoder_hidden_states=UpperCAmelCase__		,					encoder_attention_mask=UpperCAmelCase__		,					past_key_values=UpperCAmelCase__		,					output_hidden_states=UpperCAmelCase__		,					)['''hidden_states'''][0]

										# select random slice
										lowercase :							List[Any]    		=ids_tensor((1,)		,					output_from_past.shape[-1]   ).item()
										lowercase :							Any    		=output_from_no_past[:, -3:, random_slice_idx].detach()
										lowercase :							Tuple    		=output_from_past[:, :, random_slice_idx].detach()

										self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1]   )

										# test that outputs are equal for slice
										self.parent.assertTrue(torch.allclose(UpperCAmelCase__		,					UpperCAmelCase__		,					atol=1E-3   )   )







				def  lowerCamelCase_	(       self     :		Any   ):
										'''simple docstring'''
										lowercase :							Tuple    		=self.prepare_config_and_inputs()
										(
										    (
										    lowercase
										)		,	(
										    lowercase
										)		,	(
										    lowercase
										)		,	(
										    lowercase
										)		,	(
										    lowercase
										)		,	(
										    lowercase
										)		,	(
										    lowercase
										)		,	
										) :							str    		=config_and_inputs
										lowercase :							List[Any]    		={'''input_ids''': input_ids, '''attention_mask''': input_mask}
										return config, inputs_dict





@require_torch
class 		__SCREAMING_SNAKE_CASE							(			lowercase__						,							lowercase__						,							lowercase__						,							unittest.TestCase      ):
				lowerCamelCase_		       =    (
				    (OpenLlamaModel, OpenLlamaForCausalLM, OpenLlamaForSequenceClassification) if is_torch_available() else ()
				)
				lowerCamelCase_		       =    (OpenLlamaForCausalLM,) if is_torch_available() else ()
				lowerCamelCase_		       =    (
				    {
				        'feature-extraction': OpenLlamaModel,
				        'text-classification': OpenLlamaForSequenceClassification,
				        'text-generation': OpenLlamaForCausalLM,
				        'zero-shot': OpenLlamaForSequenceClassification,
				    }
				    if is_torch_available()
				    else {}
				)
				lowerCamelCase_		       =    False
				lowerCamelCase_		       =    False







				def  lowerCamelCase_	(       self     :		Any   ):
										'''simple docstring'''
										lowercase :							Any    		=OpenLlamaModelTester(self   )
										lowercase :							Dict    		=ConfigTester(self		,					config_class=UpperCAmelCase__		,					hidden_size=37   )







				def  lowerCamelCase_	(       self     :		Union[str, Any]   ):
										'''simple docstring'''
										self.config_tester.run_common_tests()







				def  lowerCamelCase_	(       self     :		List[str]   ):
										'''simple docstring'''
										lowercase :							Tuple    		=self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_model(*UpperCAmelCase__   )







				def  lowerCamelCase_	(       self     :		Optional[Any]   ):
										'''simple docstring'''
										lowercase :							Optional[int]    		=self.model_tester.prepare_config_and_inputs()
										for type in ["absolute", "relative_key", "relative_key_query"]:
																lowercase :							Dict    		=type
																self.model_tester.create_and_check_model(*UpperCAmelCase__   )







				def  lowerCamelCase_	(       self     :		int   ):
										'''simple docstring'''
										lowercase		,	lowercase :							Dict    		=self.model_tester.prepare_config_and_inputs_for_common()
										lowercase :							Optional[int]    		=3
										lowercase :							List[Any]    		=input_dict['''input_ids''']
										lowercase :							Any    		=input_ids.ne(1   ).to(UpperCAmelCase__   )
										lowercase :							Optional[Any]    		=ids_tensor([self.model_tester.batch_size]		,					self.model_tester.type_sequence_label_size   )
										lowercase :							Optional[Any]    		=OpenLlamaForSequenceClassification(UpperCAmelCase__   )
										model.to(UpperCAmelCase__   )
										model.eval()
										lowercase :							List[str]    		=model(UpperCAmelCase__		,					attention_mask=UpperCAmelCase__		,					labels=UpperCAmelCase__   )
										self.assertEqual(result.logits.shape		,					(self.model_tester.batch_size, self.model_tester.num_labels)   )







				def  lowerCamelCase_	(       self     :		Any   ):
										'''simple docstring'''
										lowercase		,	lowercase :							List[Any]    		=self.model_tester.prepare_config_and_inputs_for_common()
										lowercase :							Dict    		=3
										lowercase :							List[str]    		='''single_label_classification'''
										lowercase :							Tuple    		=input_dict['''input_ids''']
										lowercase :							Dict    		=input_ids.ne(1   ).to(UpperCAmelCase__   )
										lowercase :							List[str]    		=ids_tensor([self.model_tester.batch_size]		,					self.model_tester.type_sequence_label_size   )
										lowercase :							Dict    		=OpenLlamaForSequenceClassification(UpperCAmelCase__   )
										model.to(UpperCAmelCase__   )
										model.eval()
										lowercase :							str    		=model(UpperCAmelCase__		,					attention_mask=UpperCAmelCase__		,					labels=UpperCAmelCase__   )
										self.assertEqual(result.logits.shape		,					(self.model_tester.batch_size, self.model_tester.num_labels)   )







				def  lowerCamelCase_	(       self     :		int   ):
										'''simple docstring'''
										lowercase		,	lowercase :							str    		=self.model_tester.prepare_config_and_inputs_for_common()
										lowercase :							Optional[Any]    		=3
										lowercase :							Optional[int]    		='''multi_label_classification'''
										lowercase :							Dict    		=input_dict['''input_ids''']
										lowercase :							Optional[int]    		=input_ids.ne(1   ).to(UpperCAmelCase__   )
										lowercase :							Dict    		=ids_tensor(
										    [self.model_tester.batch_size, config.num_labels]		,					self.model_tester.type_sequence_label_size   ).to(torch.float   )
										lowercase :							str    		=OpenLlamaForSequenceClassification(UpperCAmelCase__   )
										model.to(UpperCAmelCase__   )
										model.eval()
										lowercase :							List[str]    		=model(UpperCAmelCase__		,					attention_mask=UpperCAmelCase__		,					labels=UpperCAmelCase__   )
										self.assertEqual(result.logits.shape		,					(self.model_tester.batch_size, self.model_tester.num_labels)   )







				@unittest.skip('''Open-Llama buffers include complex numbers, which breaks this test'''   )
				def  lowerCamelCase_	(       self     :		Optional[Any]   ):
										'''simple docstring'''
										pass







				@parameterized.expand([('''linear''',), ('''dynamic''',)]   )
				def  lowerCamelCase_	(       self     :		Optional[int]		,					UpperCAmelCase__     :		List[Any]   ):
										'''simple docstring'''
										lowercase		,	lowercase :							Tuple    		=self.model_tester.prepare_config_and_inputs_for_common()
										lowercase :							List[str]    		=ids_tensor([1, 10]		,					config.vocab_size   )
										lowercase :							Union[str, Any]    		=ids_tensor([1, int(config.max_position_embeddings * 1.5   )]		,					config.vocab_size   )

										set_seed(42   )  # Fixed seed at init time so the two models get the same random weights
										lowercase :							Dict    		=OpenLlamaModel(UpperCAmelCase__   )
										original_model.to(UpperCAmelCase__   )
										original_model.eval()
										lowercase :							Optional[Any]    		=original_model(UpperCAmelCase__   ).last_hidden_state
										lowercase :							Tuple    		=original_model(UpperCAmelCase__   ).last_hidden_state

										set_seed(42   )  # Fixed seed at init time so the two models get the same random weights
										lowercase :							Optional[int]    		={'''type''': scaling_type, '''factor''': 10.0}
										lowercase :							Tuple    		=OpenLlamaModel(UpperCAmelCase__   )
										scaled_model.to(UpperCAmelCase__   )
										scaled_model.eval()
										lowercase :							Optional[Any]    		=scaled_model(UpperCAmelCase__   ).last_hidden_state
										lowercase :							Optional[int]    		=scaled_model(UpperCAmelCase__   ).last_hidden_state

										# Dynamic scaling does not change the RoPE embeddings until it receives an input longer than the original
										# maximum sequence length, so the outputs for the short input should match.
										if scaling_type == "dynamic":
																self.assertTrue(torch.allclose(UpperCAmelCase__		,					UpperCAmelCase__		,					atol=1E-5   )   )
										else:
																self.assertFalse(torch.allclose(UpperCAmelCase__		,					UpperCAmelCase__		,					atol=1E-5   )   )

										# The output should be different for long inputs
										self.assertFalse(torch.allclose(UpperCAmelCase__		,					UpperCAmelCase__		,					atol=1E-5   )   )








'''simple docstring'''





from dataclasses import asdict, dataclass
from typing import Optional

from ...configuration_utils import PretrainedConfig
from ...utils import logging


UpperCamelCase_    						=       logging.get_logger(__name__)

# TODO Update this
UpperCamelCase_    						=       {
    """facebook/esm-1b""": """https://huggingface.co/facebook/esm-1b/resolve/main/config.json""",
    # See all ESM models at https://huggingface.co/models?filter=esm
}





class 		__SCREAMING_SNAKE_CASE							(			lowercase__      ):
				lowerCamelCase_		       =    'esm'







				def __init__(       self     :		Optional[Any]		,					UpperCAmelCase__     :		str=None		,					UpperCAmelCase__     :		Dict=None		,					UpperCAmelCase__     :		Any=None		,					UpperCAmelCase__     :		int=768		,					UpperCAmelCase__     :		Union[str, Any]=12		,					UpperCAmelCase__     :		List[Any]=12		,					UpperCAmelCase__     :		Optional[Any]=3072		,					UpperCAmelCase__     :		Dict=0.1		,					UpperCAmelCase__     :		int=0.1		,					UpperCAmelCase__     :		int=1026		,					UpperCAmelCase__     :		Tuple=0.02		,					UpperCAmelCase__     :		Optional[int]=1E-12		,					UpperCAmelCase__     :		List[Any]="absolute"		,					UpperCAmelCase__     :		int=True		,					UpperCAmelCase__     :		Dict=None		,					UpperCAmelCase__     :		str=False		,					UpperCAmelCase__     :		int=False		,					UpperCAmelCase__     :		Optional[Any]=None		,					UpperCAmelCase__     :		List[str]=None		,					**UpperCAmelCase__     :		int		,					):
										'''simple docstring'''
										super().__init__(pad_token_id=UpperCAmelCase__		,					mask_token_id=UpperCAmelCase__		,					**UpperCAmelCase__   )

										lowercase :							Any    		=vocab_size
										lowercase :							List[Any]    		=hidden_size
										lowercase :							Any    		=num_hidden_layers
										lowercase :							Optional[Any]    		=num_attention_heads
										lowercase :							Tuple    		=intermediate_size
										lowercase :							int    		=hidden_dropout_prob
										lowercase :							Dict    		=attention_probs_dropout_prob
										lowercase :							Optional[int]    		=max_position_embeddings
										lowercase :							Union[str, Any]    		=initializer_range
										lowercase :							Tuple    		=layer_norm_eps
										lowercase :							Union[str, Any]    		=position_embedding_type
										lowercase :							List[Any]    		=use_cache
										lowercase :							Dict    		=emb_layer_norm_before
										lowercase :							Optional[Any]    		=token_dropout
										lowercase :							Union[str, Any]    		=is_folding_model
										if is_folding_model:
																if esmfold_config is None:
																						logger.info('''No esmfold_config supplied for folding model, using default values.'''   )
																						lowercase :							Any    		=EsmFoldConfig()
																elif isinstance(UpperCAmelCase__		,					UpperCAmelCase__   ):
																						lowercase :							Optional[int]    		=EsmFoldConfig(**UpperCAmelCase__   )
																lowercase :							Union[str, Any]    		=esmfold_config
																if vocab_list is None:
																						logger.warning('''No vocab_list supplied for folding model, assuming the ESM-2 vocabulary!'''   )
																						lowercase :							int    		=get_default_vocab_list()
																else:
																						lowercase :							Tuple    		=vocab_list
										else:
																lowercase :							Union[str, Any]    		=None
																lowercase :							Dict    		=None
										if self.esmfold_config is not None and getattr(self.esmfold_config		,					'''use_esm_attn_map'''		,					UpperCAmelCase__   ):
																raise ValueError('''The HuggingFace port of ESMFold does not support use_esm_attn_map at this time!'''   )







				def  lowerCamelCase_	(       self     :		Union[str, Any]   ):
										'''simple docstring'''
										lowercase :							Union[str, Any]    		=super().to_dict()
										if isinstance(self.esmfold_config		,					UpperCAmelCase__   ):
																lowercase :							Optional[Any]    		=self.esmfold_config.to_dict()
										return output





@dataclass
class 		__SCREAMING_SNAKE_CASE							:
				lowerCamelCase_		       =    None
				lowerCamelCase_		       =    True
				lowerCamelCase_		       =    False
				lowerCamelCase_		       =    False
				lowerCamelCase_		       =    False
				lowerCamelCase_		       =    0

				lowerCamelCase_		       =    True
				lowerCamelCase_		       =    False

				lowerCamelCase_		       =    1_28
				lowerCamelCase_		       =    None







				def  lowerCamelCase_	(       self     :		Tuple   ):
										'''simple docstring'''
										if self.trunk is None:
																lowercase :							str    		=TrunkConfig()
										elif isinstance(self.trunk		,					UpperCAmelCase__   ):
																lowercase :							int    		=TrunkConfig(**self.trunk   )







				def  lowerCamelCase_	(       self     :		List[Any]   ):
										'''simple docstring'''
										lowercase :							str    		=asdict(self   )
										lowercase :							Union[str, Any]    		=self.trunk.to_dict()
										return output





@dataclass
class 		__SCREAMING_SNAKE_CASE							:
				lowerCamelCase_		       =    48
				lowerCamelCase_		       =    10_24
				lowerCamelCase_		       =    1_28
				lowerCamelCase_		       =    32
				lowerCamelCase_		       =    32
				lowerCamelCase_		       =    32
				lowerCamelCase_		       =    0
				lowerCamelCase_		       =    0
				lowerCamelCase_		       =    False
				lowerCamelCase_		       =    4
				lowerCamelCase_		       =    1_28
				lowerCamelCase_		       =    None







				def  lowerCamelCase_	(       self     :		List[str]   ):
										'''simple docstring'''
										if self.structure_module is None:
																lowercase :							Any    		=StructureModuleConfig()
										elif isinstance(self.structure_module		,					UpperCAmelCase__   ):
																lowercase :							Union[str, Any]    		=StructureModuleConfig(**self.structure_module   )

										if self.max_recycles <= 0:
																raise ValueError(F'''`max_recycles` should be positive, got {self.max_recycles}.'''   )
										if self.sequence_state_dim % self.sequence_state_dim != 0:
																raise ValueError(
																    '''`sequence_state_dim` should be a round multiple of `sequence_state_dim`, got'''
																    F''' {self.sequence_state_dim} and {self.sequence_state_dim}.'''   )
										if self.pairwise_state_dim % self.pairwise_state_dim != 0:
																raise ValueError(
																    '''`pairwise_state_dim` should be a round multiple of `pairwise_state_dim`, got'''
																    F''' {self.pairwise_state_dim} and {self.pairwise_state_dim}.'''   )

										lowercase :							str    		=self.sequence_state_dim // self.sequence_head_width
										lowercase :							int    		=self.pairwise_state_dim // self.pairwise_head_width

										if self.sequence_state_dim != sequence_num_heads * self.sequence_head_width:
																raise ValueError(
																    '''`sequence_state_dim` should be equal to `sequence_num_heads * sequence_head_width, got'''
																    F''' {self.sequence_state_dim} != {sequence_num_heads} * {self.sequence_head_width}.'''   )
										if self.pairwise_state_dim != pairwise_num_heads * self.pairwise_head_width:
																raise ValueError(
																    '''`pairwise_state_dim` should be equal to `pairwise_num_heads * pairwise_head_width, got'''
																    F''' {self.pairwise_state_dim} != {pairwise_num_heads} * {self.pairwise_head_width}.'''   )
										if self.pairwise_state_dim % 2 != 0:
																raise ValueError(F'''`pairwise_state_dim` should be even, got {self.pairwise_state_dim}.'''   )

										if self.dropout >= 0.4:
																raise ValueError(F'''`dropout` should not be greater than 0.4, got {self.dropout}.'''   )







				def  lowerCamelCase_	(       self     :		Any   ):
										'''simple docstring'''
										lowercase :							List[Any]    		=asdict(self   )
										lowercase :							Any    		=self.structure_module.to_dict()
										return output





@dataclass
class 		__SCREAMING_SNAKE_CASE							:
				lowerCamelCase_		       =    3_84
				lowerCamelCase_		       =    1_28
				lowerCamelCase_		       =    16
				lowerCamelCase_		       =    1_28
				lowerCamelCase_		       =    12
				lowerCamelCase_		       =    4
				lowerCamelCase_		       =    8
				lowerCamelCase_		       =    0.1
				lowerCamelCase_		       =    8
				lowerCamelCase_		       =    1
				lowerCamelCase_		       =    2
				lowerCamelCase_		       =    7
				lowerCamelCase_		       =    10
				lowerCamelCase_		       =    1E-8
				lowerCamelCase_		       =    1E5







				def  lowerCamelCase_	(       self     :		Dict   ):
										'''simple docstring'''
										return asdict(self   )






def 				_lowerCAmelCase			(   )				->  Optional[int]:
						return (
						    "<cls>",
						    "<pad>",
						    "<eos>",
						    "<unk>",
						    "L",
						    "A",
						    "G",
						    "V",
						    "S",
						    "E",
						    "R",
						    "T",
						    "I",
						    "D",
						    "P",
						    "K",
						    "Q",
						    "N",
						    "F",
						    "Y",
						    "M",
						    "H",
						    "W",
						    "C",
						    "X",
						    "B",
						    "U",
						    "Z",
						    "O",
						    ".",
						    "-",
						    "<null_1>",
						    "<mask>",
						)





