



'''simple docstring'''

import copy
import os
import tempfile
from unittest import TestCase
from unittest.mock import patch

import numpy as np
import pyarrow as pa
import pyarrow.parquet as pq
import pytest

from datasets.arrow_writer import ArrowWriter, OptimizedTypedSequence, ParquetWriter, TypedSequence
from datasets.features import ArrayaD, ClassLabel, Features, Image, Value
from datasets.features.features import ArrayaDExtensionType, cast_to_python_objects
from datasets.keyhash import DuplicatedKeysError, InvalidKeyError

from .utils import require_pil

class       __magic_name__		(       _UpperCamelCase  ):







							def 				__lowercase     (				self   :			List[str]						):
									_a	: Optional[Any]								=				pa.array(TypedSequence([1, 2, 3]						)						)
									self.assertEqual(arr.type      ,pa.intaa()						)







							def 				__lowercase     (				self   :			Union[str, Any]						):
									with self.assertRaises(_UpperCAmelCase						):
											_a	: int								=				pa.array(TypedSequence([1, 2, 3]						)      ,type=pa.intaa()						)







							def 				__lowercase     (				self   :			Tuple						):
									with self.assertRaises(_UpperCAmelCase						):
											_a	: Union[str, Any]								=				pa.array(TypedSequence([1, 2, 3]      ,try_type=Value('bool'						)      ,type=Value('int64'						)						)						)







							def 				__lowercase     (				self   :			Union[str, Any]						):
									_a	: Optional[int]								=				pa.array(TypedSequence([1, 2, 3]      ,type=Value('int32'						)						)						)
									self.assertEqual(arr.type      ,pa.intaa()						)







							def 				__lowercase     (				self   :			Union[str, Any]						):
									with self.assertRaises((TypeError, pa.lib.ArrowInvalid)						):
											_a	: Tuple								=				pa.array(TypedSequence(['foo', 'bar']      ,type=Value('int64'						)						)						)







							def 				__lowercase     (				self   :			str						):
									_a	: Union[str, Any]								=				pa.array(TypedSequence([1, 2, 3]      ,try_type=Value('int32'						)						)						)
									self.assertEqual(arr.type      ,pa.intaa()						)







							def 				__lowercase     (				self   :			Union[str, Any]						):
									_a	: List[Any]								=				pa.array(TypedSequence(['foo', 'bar']      ,try_type=Value('int64'						)						)						)
									self.assertEqual(arr.type      ,pa.string()						)







							def 				__lowercase     (				self   :			Any						):
									_a	: int								=				pa.array(TypedSequence([[[1, 2, 3]]]      ,type=ArrayaD((1, 3)      ,'int64'						)						)						)
									self.assertEqual(arr.type      ,ArrayaDExtensionType((1, 3)      ,'int64'						)						)







							def 				__lowercase     (				self   :			Union[str, Any]						):
									with self.assertRaises((TypeError, pa.lib.ArrowInvalid)						):
											_a	: Union[str, Any]								=				pa.array(TypedSequence(['foo', 'bar']      ,type=ArrayaD((1, 3)      ,'int64'						)						)						)







							def 				__lowercase     (				self   :			Optional[int]						):
									_a	: Union[str, Any]								=				pa.array(TypedSequence([[[1, 2, 3]]]      ,try_type=ArrayaD((1, 3)      ,'int64'						)						)						)
									self.assertEqual(arr.type      ,ArrayaDExtensionType((1, 3)      ,'int64'						)						)







							def 				__lowercase     (				self   :			Dict						):
									_a	: Any								=				pa.array(TypedSequence(['foo', 'bar']      ,try_type=ArrayaD((1, 3)      ,'int64'						)						)						)
									self.assertEqual(arr.type      ,pa.string()						)







							@require_pil
							def 				__lowercase     (				self   :			Tuple						):
									import PIL.Image

									_a	: Union[str, Any]								=				PIL.Image.fromarray(np.arange(10      ,dtype=np.uinta						).reshape(2      ,5						)						)
									with patch(
									    'datasets.arrow_writer.cast_to_python_objects'      ,side_effect=_UpperCAmelCase						) as mock_cast_to_python_objects:
											_a	: Optional[Any]								=				pa.array(TypedSequence([{'path': None, 'bytes': B'image_bytes'}, pil_image]      ,type=Image()						)						)
											_a			,   _a	: int								=				mock_cast_to_python_objects.call_args_list[-1]
											self.assertIn('optimize_list_casting'      ,_UpperCAmelCase						)
											self.assertFalse(kwargs['optimize_list_casting']						)



def 	__lowerCamelCase	( lowerCAmelCase_		,     lowerCAmelCase_    )     -> Optional[int]:
		_a	: str								=				pa.BufferReader(lowerCAmelCase_    ) if isinstance(lowerCAmelCase_		,     pa.Buffer    ) else pa.memory_map(lowerCAmelCase_    )
		_a	: Dict								=				pa.ipc.open_stream(lowerCAmelCase_    )
		_a	: pa.Table								=				f.read_all()
		assert len(pa_table.to_batches()    ) == expected_num_chunks
		assert pa_table.to_pydict() == {"col_1": ["foo", "bar"], "col_2": [1, 2]}
		del pa_table



@pytest.mark.parametrize('writer_batch_size'		,     [None, 1, 10]    )
@pytest.mark.parametrize(
    'fields'		,     [None, {'col_1': pa.string(), 'col_2': pa.intaa()}, {'col_1': pa.string(), 'col_2': pa.intaa()}]    )
def 	__lowerCamelCase	( lowerCAmelCase_		,     lowerCAmelCase_    )     -> Optional[int]:
		_a	: Any								=				pa.BufferOutputStream()
		_a	: Any								=				pa.schema(lowerCAmelCase_    ) if fields else None
		with ArrowWriter(stream=lowerCAmelCase_		,     schema=lowerCAmelCase_		,     writer_batch_size=lowerCAmelCase_    ) as writer:
				writer.write({'col_1': 'foo', 'col_2': 1}    )
				writer.write({'col_1': 'bar', 'col_2': 2}    )
				_a			,   _a	: Union[str, Any]								=				writer.finalize()
		assert num_examples == 2
		assert num_bytes > 0
		if not fields:
				_a	: str								=				{'col_1': pa.string(), 'col_2': pa.intaa()}
		assert writer._schema == pa.schema(lowerCAmelCase_		,     metadata=writer._schema.metadata    )
		_check_output(output.getvalue()		,     expected_num_chunks=num_examples if writer_batch_size == 1 else 1    )



def 	__lowerCamelCase	( )     -> str:
		_a	: List[Any]								=				pa.BufferOutputStream()
		_a	: Tuple								=				Features({'labels': ClassLabel(names=['neg', 'pos']    )}    )
		with ArrowWriter(stream=lowerCAmelCase_		,     features=lowerCAmelCase_    ) as writer:
				writer.write({'labels': 0}    )
				writer.write({'labels': 1}    )
				_a			,   _a	: Optional[int]								=				writer.finalize()
		assert num_examples == 2
		assert num_bytes > 0
		assert writer._schema == features.arrow_schema
		assert writer._schema.metadata == features.arrow_schema.metadata
		_a	: Optional[int]								=				pa.BufferReader(output.getvalue()    )
		_a	: Optional[int]								=				pa.ipc.open_stream(lowerCAmelCase_    )
		_a	: pa.Table								=				f.read_all()
		_a	: str								=				pa_table.schema
		assert pa_table.num_rows == 2
		assert schema == features.arrow_schema
		assert schema.metadata == features.arrow_schema.metadata
		assert features == Features.from_arrow_schema(lowerCAmelCase_    )



@pytest.mark.parametrize('writer_batch_size'		,     [None, 1, 10]    )
def 	__lowerCamelCase	( lowerCAmelCase_    )     -> Union[str, Any]:
		_a	: List[Any]								=				pa.BufferOutputStream()
		with ArrowWriter(
		    stream=lowerCAmelCase_		,     writer_batch_size=lowerCAmelCase_		,     hash_salt='split_name'		,     check_duplicates=lowerCAmelCase_		,     ) as writer:
				with pytest.raises(lowerCAmelCase_    ):
						writer.write({'col_1': 'foo', 'col_2': 1}		,     key=[1, 2]    )
						_a			,   _a	: str								=				writer.finalize()



@pytest.mark.parametrize('writer_batch_size'		,     [None, 2, 10]    )
def 	__lowerCamelCase	( lowerCAmelCase_    )     -> Tuple:
		_a	: Tuple								=				pa.BufferOutputStream()
		with ArrowWriter(
		    stream=lowerCAmelCase_		,     writer_batch_size=lowerCAmelCase_		,     hash_salt='split_name'		,     check_duplicates=lowerCAmelCase_		,     ) as writer:
				with pytest.raises(lowerCAmelCase_    ):
						writer.write({'col_1': 'foo', 'col_2': 1}		,     key=10    )
						writer.write({'col_1': 'bar', 'col_2': 2}		,     key=10    )
						_a			,   _a	: str								=				writer.finalize()



@pytest.mark.parametrize('writer_batch_size'		,     [None, 2, 10]    )
def 	__lowerCamelCase	( lowerCAmelCase_    )     -> Tuple:
		_a	: Union[str, Any]								=				pa.BufferOutputStream()
		with ArrowWriter(
		    stream=lowerCAmelCase_		,     writer_batch_size=lowerCAmelCase_		,     hash_salt='split_name'		,     check_duplicates=lowerCAmelCase_		,     ) as writer:
				writer.write({'col_1': 'foo', 'col_2': 1}		,     key=1    )
				writer.write({'col_1': 'bar', 'col_2': 2}		,     key=2    )
				_a			,   _a	: str								=				writer.finalize()
		assert num_examples == 2
		assert num_bytes > 0
		_check_output(output.getvalue()		,     expected_num_chunks=num_examples if writer_batch_size == 1 else 1    )



@pytest.mark.parametrize('writer_batch_size'		,     [None, 1, 10]    )
@pytest.mark.parametrize(
    'fields'		,     [None, {'col_1': pa.string(), 'col_2': pa.intaa()}, {'col_1': pa.string(), 'col_2': pa.intaa()}]    )
def 	__lowerCamelCase	( lowerCAmelCase_		,     lowerCAmelCase_    )     -> Union[str, Any]:
		_a	: Any								=				pa.BufferOutputStream()
		_a	: Tuple								=				pa.schema(lowerCAmelCase_    ) if fields else None
		with ArrowWriter(stream=lowerCAmelCase_		,     schema=lowerCAmelCase_		,     writer_batch_size=lowerCAmelCase_    ) as writer:
				writer.write_batch({'col_1': ['foo', 'bar'], 'col_2': [1, 2]}    )
				writer.write_batch({'col_1': [], 'col_2': []}    )
				_a			,   _a	: Optional[Any]								=				writer.finalize()
		assert num_examples == 2
		assert num_bytes > 0
		if not fields:
				_a	: Optional[Any]								=				{'col_1': pa.string(), 'col_2': pa.intaa()}
		assert writer._schema == pa.schema(lowerCAmelCase_		,     metadata=writer._schema.metadata    )
		_check_output(output.getvalue()		,     expected_num_chunks=num_examples if writer_batch_size == 1 else 1    )



@pytest.mark.parametrize('writer_batch_size'		,     [None, 1, 10]    )
@pytest.mark.parametrize(
    'fields'		,     [None, {'col_1': pa.string(), 'col_2': pa.intaa()}, {'col_1': pa.string(), 'col_2': pa.intaa()}]    )
def 	__lowerCamelCase	( lowerCAmelCase_		,     lowerCAmelCase_    )     -> Dict:
		_a	: Tuple								=				pa.BufferOutputStream()
		_a	: Optional[Any]								=				pa.schema(lowerCAmelCase_    ) if fields else None
		with ArrowWriter(stream=lowerCAmelCase_		,     schema=lowerCAmelCase_		,     writer_batch_size=lowerCAmelCase_    ) as writer:
				writer.write_table(pa.Table.from_pydict({'col_1': ['foo', 'bar'], 'col_2': [1, 2]}    )    )
				_a			,   _a	: Tuple								=				writer.finalize()
		assert num_examples == 2
		assert num_bytes > 0
		if not fields:
				_a	: Dict								=				{'col_1': pa.string(), 'col_2': pa.intaa()}
		assert writer._schema == pa.schema(lowerCAmelCase_		,     metadata=writer._schema.metadata    )
		_check_output(output.getvalue()		,     expected_num_chunks=num_examples if writer_batch_size == 1 else 1    )



@pytest.mark.parametrize('writer_batch_size'		,     [None, 1, 10]    )
@pytest.mark.parametrize(
    'fields'		,     [None, {'col_1': pa.string(), 'col_2': pa.intaa()}, {'col_1': pa.string(), 'col_2': pa.intaa()}]    )
def 	__lowerCamelCase	( lowerCAmelCase_		,     lowerCAmelCase_    )     -> int:
		_a	: Optional[Any]								=				pa.BufferOutputStream()
		_a	: str								=				pa.schema(lowerCAmelCase_    ) if fields else None
		with ArrowWriter(stream=lowerCAmelCase_		,     schema=lowerCAmelCase_		,     writer_batch_size=lowerCAmelCase_    ) as writer:
				writer.write_row(pa.Table.from_pydict({'col_1': ['foo'], 'col_2': [1]}    )    )
				writer.write_row(pa.Table.from_pydict({'col_1': ['bar'], 'col_2': [2]}    )    )
				_a			,   _a	: str								=				writer.finalize()
		assert num_examples == 2
		assert num_bytes > 0
		if not fields:
				_a	: List[str]								=				{'col_1': pa.string(), 'col_2': pa.intaa()}
		assert writer._schema == pa.schema(lowerCAmelCase_		,     metadata=writer._schema.metadata    )
		_check_output(output.getvalue()		,     expected_num_chunks=num_examples if writer_batch_size == 1 else 1    )



def 	__lowerCamelCase	( )     -> Tuple:
		with tempfile.TemporaryDirectory() as tmp_dir:
				_a	: Optional[Any]								=				{'col_1': pa.string(), 'col_2': pa.intaa()}
				_a	: int								=				os.path.join(lowerCAmelCase_		,     'test.arrow'    )
				with ArrowWriter(path=lowerCAmelCase_		,     schema=pa.schema(lowerCAmelCase_    )    ) as writer:
						writer.write_batch({'col_1': ['foo', 'bar'], 'col_2': [1, 2]}    )
						_a			,   _a	: Any								=				writer.finalize()
				assert num_examples == 2
				assert num_bytes > 0
				assert writer._schema == pa.schema(lowerCAmelCase_		,     metadata=writer._schema.metadata    )
				_check_output(lowerCAmelCase_		,     1    )



def 	__lowerCamelCase	( lowerCAmelCase_    )     -> Optional[int]:
		if pa.types.is_list(lowerCAmelCase_    ):
				return get_base_dtype(arr_type.value_type    )
		else:
				return arr_type



def 	__lowerCamelCase	( lowerCAmelCase_		,     lowerCAmelCase_    )     -> List[str]:
		if isinstance(lst[0]		,     lowerCAmelCase_    ):
				change_first_primitive_element_in_list(lst[0]		,     lowerCAmelCase_    )
		else:
				_a	: Dict								=				value



@pytest.mark.parametrize('optimized_int_type, expected_dtype'		,     [(None, pa.intaa()), (Value('int32'    ), pa.intaa())]    )
@pytest.mark.parametrize('sequence'		,     [[1, 2, 3], [[1, 2, 3]], [[[1, 2, 3]]]]    )
def 	__lowerCamelCase	( lowerCAmelCase_		,     lowerCAmelCase_		,     lowerCAmelCase_    )     -> Dict:
		_a	: Union[str, Any]								=				pa.array(TypedSequence(lowerCAmelCase_		,     optimized_int_type=lowerCAmelCase_    )    )
		assert get_base_dtype(arr.type    ) == expected_dtype



@pytest.mark.parametrize(
    'col, expected_dtype'		,     [
        ('attention_mask', pa.inta()),
        ('special_tokens_mask', pa.inta()),
        ('token_type_ids', pa.inta()),
        ('input_ids', pa.intaa()),
        ('other', pa.intaa()),
    ]		,     )
@pytest.mark.parametrize('sequence'		,     [[1, 2, 3], [[1, 2, 3]], [[[1, 2, 3]]]]    )
def 	__lowerCamelCase	( lowerCAmelCase_		,     lowerCAmelCase_		,     lowerCAmelCase_    )     -> int:
		# in range
		_a	: Dict								=				pa.array(OptimizedTypedSequence(lowerCAmelCase_		,     col=lowerCAmelCase_    )    )
		assert get_base_dtype(arr.type    ) == expected_dtype

		# not in range
		if col != "other":
				# avoids errors due to in-place modifications
				_a	: Union[str, Any]								=				copy.deepcopy(lowerCAmelCase_    )
				_a	: Any								=				np.iinfo(expected_dtype.to_pandas_dtype()    ).max + 1
				change_first_primitive_element_in_list(lowerCAmelCase_		,     lowerCAmelCase_    )
				_a	: int								=				pa.array(OptimizedTypedSequence(lowerCAmelCase_		,     col=lowerCAmelCase_    )    )
				assert get_base_dtype(arr.type    ) == pa.intaa()



@pytest.mark.parametrize('raise_exception'		,     [False, True]    )
def 	__lowerCamelCase	( lowerCAmelCase_		,     lowerCAmelCase_    )     -> Optional[Any]:
		_a	: int								=				str(tmp_path / 'dataset-train.arrow'    )
		try:
				with ArrowWriter(path=lowerCAmelCase_    ) as writer:
						if raise_exception:
								raise pa.lib.ArrowInvalid()
						else:
								writer.stream.close()
		except pa.lib.ArrowInvalid:
				pass
		finally:
				assert writer.stream.closed



def 	__lowerCamelCase	( lowerCAmelCase_    )     -> List[Any]:
		_a	: Optional[int]								=				'mock://dataset-train.arrow'
		with ArrowWriter(path=lowerCAmelCase_		,     storage_options=mockfs.storage_options    ) as writer:
				assert isinstance(writer._fs		,     type(lowerCAmelCase_    )    )
				assert writer._fs.storage_options == mockfs.storage_options
				writer.write({'col_1': 'foo', 'col_2': 1}    )
				writer.write({'col_1': 'bar', 'col_2': 2}    )
				_a			,   _a	: Dict								=				writer.finalize()
		assert num_examples == 2
		assert num_bytes > 0
		assert mockfs.exists(lowerCAmelCase_    )



def 	__lowerCamelCase	( )     -> Union[str, Any]:
		_a	: List[Any]								=				pa.BufferOutputStream()
		with ParquetWriter(stream=lowerCAmelCase_    ) as writer:
				writer.write({'col_1': 'foo', 'col_2': 1}    )
				writer.write({'col_1': 'bar', 'col_2': 2}    )
				_a			,   _a	: List[Any]								=				writer.finalize()
		assert num_examples == 2
		assert num_bytes > 0
		_a	: List[Any]								=				pa.BufferReader(output.getvalue()    )
		_a	: pa.Table								=				pq.read_table(lowerCAmelCase_    )
		assert pa_table.to_pydict() == {"col_1": ["foo", "bar"], "col_2": [1, 2]}



@require_pil
@pytest.mark.parametrize('embed_local_files'		,     [False, True]    )
def 	__lowerCamelCase	( lowerCAmelCase_		,     lowerCAmelCase_    )     -> str:
		import PIL.Image

		_a	: int								=				str(tmp_path / 'test_image_rgb.jpg'    )
		PIL.Image.fromarray(np.zeros((5, 5)		,     dtype=np.uinta    )    ).save(lowerCAmelCase_		,     format='png'    )
		_a	: Optional[Any]								=				pa.BufferOutputStream()
		with ParquetWriter(
		    stream=lowerCAmelCase_		,     features=Features({'image': Image()}    )		,     embed_local_files=lowerCAmelCase_    ) as writer:
				writer.write({'image': image_path}    )
				writer.finalize()
		_a	: Union[str, Any]								=				pa.BufferReader(output.getvalue()    )
		_a	: pa.Table								=				pq.read_table(lowerCAmelCase_    )
		_a	: Union[str, Any]								=				pa_table.to_pydict()
		if embed_local_files:
				assert isinstance(out['image'][0]['path']		,     lowerCAmelCase_    )
				with open(lowerCAmelCase_		,     'rb'    ) as f:
						assert out["image"][0]["bytes"] == f.read()
		else:
				assert out["image"][0]["path"] == image_path
				assert out["image"][0]["bytes"] is None



def 	__lowerCamelCase	( )     -> Union[str, Any]:
		_a	: Any								=				pa.schema([pa.field('col_1'		,     pa.string()		,     nullable=lowerCAmelCase_    )]    )
		_a	: List[str]								=				pa.BufferOutputStream()
		with ArrowWriter(stream=lowerCAmelCase_    ) as writer:
				writer._build_writer(inferred_schema=lowerCAmelCase_    )
				assert writer._schema == pa.schema([pa.field('col_1'		,     pa.string()    )]    )









'''simple docstring'''

from dataclasses import asdict, dataclass
from typing import Optional

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


__lowerCAmelCase		     =  logging.get_logger(__name__)

# TODO Update this
__lowerCAmelCase		     =  {
    '''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       __magic_name__		(       _UpperCamelCase  ):
							lowerCAmelCase			:       Any  							=   'esm'







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

									_a	: Optional[Any]								=				vocab_size
									_a	: Union[str, Any]								=				hidden_size
									_a	: Dict								=				num_hidden_layers
									_a	: int								=				num_attention_heads
									_a	: Dict								=				intermediate_size
									_a	: List[Any]								=				hidden_dropout_prob
									_a	: List[Any]								=				attention_probs_dropout_prob
									_a	: Optional[Any]								=				max_position_embeddings
									_a	: Optional[int]								=				initializer_range
									_a	: List[Any]								=				layer_norm_eps
									_a	: int								=				position_embedding_type
									_a	: Optional[int]								=				use_cache
									_a	: Any								=				emb_layer_norm_before
									_a	: List[str]								=				token_dropout
									_a	: List[str]								=				is_folding_model
									if is_folding_model:
											if esmfold_config is None:
													logger.info('No esmfold_config supplied for folding model, using default values.'						)
													_a	: Dict								=				EsmFoldConfig()
											elif isinstance(_UpperCAmelCase      ,_UpperCAmelCase						):
													_a	: Dict								=				EsmFoldConfig(**_UpperCAmelCase						)
											_a	: Optional[int]								=				esmfold_config
											if vocab_list is None:
													logger.warning('No vocab_list supplied for folding model, assuming the ESM-2 vocabulary!'						)
													_a	: Optional[int]								=				get_default_vocab_list()
											else:
													_a	: Optional[int]								=				vocab_list
									else:
											_a	: Optional[Any]								=				None
											_a	: Union[str, Any]								=				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 				__lowercase     (				self   :			Any						):
									_a	: str								=				super().to_dict()
									if isinstance(self.esmfold_config      ,_UpperCAmelCase						):
											_a	: List[str]								=				self.esmfold_config.to_dict()
									return output

@dataclass
class       __magic_name__		:
							lowerCAmelCase			:       str  							=   None
							lowerCAmelCase			:       bool  							=   True
							lowerCAmelCase			:       bool  							=   False
							lowerCAmelCase			:       bool  							=   False
							lowerCAmelCase			:       bool  							=   False
							lowerCAmelCase			:       float  							=   0

							lowerCAmelCase			:       bool  							=   True
							lowerCAmelCase			:       bool  							=   False

							lowerCAmelCase			:       int  							=   1_2_8
							lowerCAmelCase			:       "TrunkConfig"  							=   None







							def 				__lowercase     (				self   :			List[str]						):
									if self.trunk is None:
											_a	: Dict								=				TrunkConfig()
									elif isinstance(self.trunk      ,_UpperCAmelCase						):
											_a	: str								=				TrunkConfig(**self.trunk						)







							def 				__lowercase     (				self   :			List[Any]						):
									_a	: List[str]								=				asdict(self						)
									_a	: List[str]								=				self.trunk.to_dict()
									return output

@dataclass
class       __magic_name__		:
							lowerCAmelCase			:       int  							=   4_8
							lowerCAmelCase			:       int  							=   1_0_2_4
							lowerCAmelCase			:       int  							=   1_2_8
							lowerCAmelCase			:       int  							=   3_2
							lowerCAmelCase			:       int  							=   3_2
							lowerCAmelCase			:       int  							=   3_2
							lowerCAmelCase			:       float  							=   0
							lowerCAmelCase			:       float  							=   0
							lowerCAmelCase			:       bool  							=   False
							lowerCAmelCase			:       int  							=   4
							lowerCAmelCase			:       Optional[int]  							=   1_2_8
							lowerCAmelCase			:       "StructureModuleConfig"  							=   None







							def 				__lowercase     (				self   :			str						):
									if self.structure_module is None:
											_a	: Tuple								=				StructureModuleConfig()
									elif isinstance(self.structure_module      ,_UpperCAmelCase						):
											_a	: List[str]								=				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}."""						)

									_a	: Optional[int]								=				self.sequence_state_dim // self.sequence_head_width
									_a	: 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 				__lowercase     (				self   :			Optional[int]						):
									_a	: Optional[Any]								=				asdict(self						)
									_a	: Optional[Any]								=				self.structure_module.to_dict()
									return output

@dataclass
class       __magic_name__		:
							lowerCAmelCase			:       int  							=   3_8_4
							lowerCAmelCase			:       int  							=   1_2_8
							lowerCAmelCase			:       int  							=   1_6
							lowerCAmelCase			:       int  							=   1_2_8
							lowerCAmelCase			:       int  							=   1_2
							lowerCAmelCase			:       int  							=   4
							lowerCAmelCase			:       int  							=   8
							lowerCAmelCase			:       float  							=   0.1
							lowerCAmelCase			:       int  							=   8
							lowerCAmelCase			:       int  							=   1
							lowerCAmelCase			:       int  							=   2
							lowerCAmelCase			:       int  							=   7
							lowerCAmelCase			:       int  							=   1_0
							lowerCAmelCase			:       float  							=   1e-8
							lowerCAmelCase			:       float  							=   1e5







							def 				__lowercase     (				self   :			str						):
									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>",
		)




