
    Z jk'                        S r SSKJr  SSKJr  SSKJr  SSKJrJ	r	  SSK
JrJr  \	R                  " \5      r\ " S S	\5      5       r\ " S
 S\5      5       r\ " S S\5      5       r\" SS9\ " S S\5      5       5       rS rS/rg)zESM model configuration    )Union)strict   )PreTrainedConfig)auto_docstringlogging)intervalis_divisible_byc                   F   \ rS rSr% SrSr\S-  \S'   Sr\S-  \S'   Sr	\S-  \S	'   Sr
\S-  \S
'   Sr\S-  \S'   Sr\S-  \S'   Sr\S-  \S'   Sr\S-  \S'   Sr\S-  \S'   Sr\S-  \S'   Sr\S-  \S'   Sr\S-  \S'   Sr\S-  \S'   Sr\S-  \S'   Sr\S-  \S'   S rg)!StructureModuleConfig   a$  
Args:
    sequence_dim:
        Single representation channel dimension
    pairwise_dim:
        Pair representation channel dimension
    ipa_dim:
        IPA hidden channel dimension
    resnet_dim:
        Angle resnet (Alg. 23 lines 11-14) hidden channel dimension
    num_heads_ipa:
        Number of IPA heads
    num_qk_points:
        Number of query/key points to generate during IPA
    num_v_points:
        Number of value points to generate during IPA
    dropout_rate:
        Dropout rate used throughout the layer
    num_blocks:
        Number of structure module blocks
    num_transition_layers:
        Number of layers in the single representation transition (Alg. 23 lines 8-9)
    num_resnet_blocks:
        Number of blocks in the angle resnet
    num_angles:
        Number of angles to generate in the angle resnet
    trans_scale_factor:
        Scale of single representation transition hidden dimension
    epsilon:
        Small number used in angle resnet normalization
    inf:
        Large number used for attention masking
i  Nsequence_dim   pairwise_dim   ipa_dim
resnet_dim   num_heads_ipa   num_qk_points   num_v_points皙?dropout_rate
num_blocks   num_transition_layers   num_resnet_blocks   
num_angles
   trans_scale_factorg:0yE>epsilong     j@inf )__name__
__module____qualname____firstlineno____doc__r   int__annotations__r   r   r   r   r   r   r   floatr   r   r    r"   r$   r%   r&   __static_attributes__r'       z/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/transformers/models/esm/configuration_esm.pyr   r      s     D  #L#*""L#*"GS4Z Jd
  "M3:" !M3:! L#* !$L%$,$Jd
()3:)$%sTz%Jd
%'d
' GUT\ Cr1   r   c                   n  ^  \ rS rSr% S\0rSr\S-  \S'   Sr	\S-  \S'   \
" SS	9" S
S9r\S-  \S'   Sr\S-  \S'   Sr\S-  \S'   Sr\S-  \S'   \" SS9" SS9r\\-  S-  \S'   Sr\\-  S-  \S'   Sr\S-  \S'   \" SS9" SS9r\S-  \S'   S
r\S-  \S'   Sr\\S4   S-  \S'   U 4S jrS rS rU =r$ )!TrunkConfigQ   structure_module0   Nr   i   sequence_state_dimr   )divisorr   )defaultpairwise_state_dim    sequence_head_widthpairwise_head_widthposition_binsg?)max        dropout
layer_dropFcpu_grad_checkpointr   )minr   max_recycles
chunk_sizer   c                    > U R                   c  [        5       U l         O9[        U R                   [        5      (       a  [        S0 U R                   D6U l         [        TU ]  " S0 UD6  g Nr'   )r6   r   
isinstancedictsuper__post_init__selfkwargs	__class__s     r2   rM   TrunkConfig.__post_init__b   sS      ($9$;D!--t44$9$RD<Q<Q$RD!''r1   c           	         U R                   U R                   -  S:w  a&  [        SU R                    SU R                    S35      eU R                  U R                  -  S:w  a&  [        SU R                   SU R                   S35      eU R                   U R                  -  nU R                  U R                  -  nU R                   XR                  -  :w  a)  [        SU R                    SU SU R                   S35      eU R                  X R                  -  :w  a)  [        S	U R                   SU SU R                   S35      eg )
Nr   zM`sequence_state_dim` should be a round multiple of `sequence_state_dim`, got z and .zM`pairwise_state_dim` should be a round multiple of `pairwise_state_dim`, got zW`sequence_state_dim` should be equal to `sequence_num_heads * sequence_head_width, got z != z * zW`pairwise_state_dim` should be equal to `pairwise_num_heads * pairwise_head_width, got )r8   
ValueErrorr;   r=   r>   )rO   sequence_num_headspairwise_num_headss      r2   validate_architecture!TrunkConfig.validate_architecturei   s|   ""T%<%<<A++,E$2I2I1J!M  ""T%<%<<A++,E$2I2I1J!M 
 "448P8PP!448P8PP""&8;S;S&SS++,D1C0DCH`H`Gaabd  ""&8;S;S&SS++,D1C0DCH`H`Gaabd  Tr1   )r6   )r(   r)   r*   r+   r   sub_configsr   r-   r.   r8   r
   r;   r=   r>   r?   r	   rB   r/   rC   rD   boolrF   rG   r6   r   rK   rM   rX   r0   __classcell__rQ   s   @r2   r4   r4   Q   s    %'<=KJd
%)d
)%4Q%?%Ld
L&(t(&(t( "M3:""*s"3C"@GUS[4@%(Jd"(',,'Aq9L#*9 Jd
 DHeD"99:TAH( r1   r4   c                   
  ^  \ rS rSr% S\0rSr\S-  \S'   Sr	\
S-  \S'   Sr\
S-  \S'   Sr\
S-  \S	'   Sr\
S-  \S
'   Sr\\-  S-  \S'   Sr\
S-  \S'   Sr\
S-  \S'   Sr\S-  \S'   Sr\\S4   S-  \S'   U 4S jrSrU =r$ )EsmFoldConfig   trunkNesm_typeTfp16_esmFuse_esm_attn_mapesm_ablate_pairwiseesm_ablate_sequencerA   esm_input_dropoutembed_aa	bypass_lmr   lddt_head_hid_dimr4   c                    > U R                   c  [        5       U l         O9[        U R                   [        5      (       a  [        S0 U R                   D6U l         [        TU ]  " S0 UD6  g rI   )ra   r4   rJ   rK   rL   rM   rN   s     r2   rM   EsmFoldConfig.__post_init__   sJ    ::$DJ

D))$2tzz2DJ''r1   )ra   )r(   r)   r*   r+   r4   rZ   rb   strr.   rc   r[   rd   re   rf   rg   r/   r-   rh   ri   rj   ra   r   rK   rM   r0   r\   r]   s   @r2   r_   r_      s    K(KHcDj HdTk $)dTk)',,',,,/us{T)/ HdTk "Itd{"$'sTz'/3E5}$%,3( (r1   r_   zfacebook/esm-1b)
checkpointc                      ^  \ rS rSr% SrSrS\0rSr\	S-  \
S'   Sr\	S-  \
S'   Sr\	S-  \
S'   S	r\	\
S
'   Sr\	\
S'   Sr\	\
S'   Sr\	\
S'   Sr\S-  \
S'   Sr\S-  \
S'   Sr\	\
S'   Sr\\
S'   Sr\\
S'   Sr\S-  \
S'   Sr\S-  \
S'   Sr\\
S'   Sr\S-  \
S'   S r\S-  \
S!'   S r\S-  \
S"'   Sr\ \-  S-  \
S'   Sr!\"\   \#\S#4   -  S-  \
S$'   S r$\S-  \
S%'   S r%\S-  \
S&'   Sr&\\
S''   Sr'\	S-  \
S('   S)r(\	\"\	   -  S-  \
S*'   U 4S+ jr)S,r*U =r+$ )-	EsmConfig   a  
mask_token_id (`int`, *optional*):
    The index of the mask token in the vocabulary. This must be included in the config because of the
    "mask-dropout" scaling trick, which will scale the inputs depending on the number of masked tokens.
rope_theta (`float`, defaults to 10000.0):
    The base period of the RoPE embeddings. Only used when `position_embedding_type` is set to `"rotary"`.
position_embedding_type (`str`, *optional*, defaults to `"absolute"`):
    Type of position embedding. Choose either `"absolute"` or "rotary"`.
emb_layer_norm_before (`bool`, *optional*):
    Whether to apply layer normalization after embeddings but before the main stem of the network.
token_dropout (`bool`, defaults to `False`):
    When this is enabled, masked tokens are treated as if they had been dropped out by input dropout.
is_folding_model (`bool`, defaults to `False`):
    When this is enabled, ESMFold model will be initialized.
esmfold_config (`dict`, *optional*):
    Configuration to initiate the ESMFold module.
vocab_list (`list`, *optional*):
    List of the vocabulary items.

Examples:

```python
>>> from transformers import EsmModel, EsmConfig

>>> # Initializing a ESM facebook/esm-1b style configuration
>>> configuration = EsmConfig(vocab_size=33)

>>> # Initializing a model from the configuration
>>> model = EsmModel(configuration)

>>> # Accessing the model configuration
>>> configuration = model.config
```esmesmfold_configN
vocab_sizemask_token_idpad_token_idi   hidden_sizer   num_hidden_layersnum_attention_headsi   intermediate_sizer   hidden_dropout_probattention_probs_dropout_probi  max_position_embeddingsg     @
rope_thetag{Gz?initializer_rangeg-q=layer_norm_epsabsoluteposition_embedding_typeT	use_cacheemb_layer_norm_beforeFtoken_dropoutis_folding_model.
vocab_list
is_decoderadd_cross_attentiontie_word_embeddingsbos_token_idr   eos_token_idc                   > U R                   (       a  U R                  c%  [        R                  S5        [	        5       U l        O9[        U R                  [        5      (       a  [	        S0 U R                  D6U l        U R                  c$  [        R                  S5        [        5       U l        OS U l        S U l        U R                  b'  [        U R                  SS5      (       a  [        S5      e[        TU ]4  " S0 UD6  g )NzCNo esmfold_config supplied for folding model, using default values.zHNo vocab_list supplied for folding model, assuming the ESM-2 vocabulary!rd   FzOThe HuggingFace port of ESMFold does not support use_esm_attn_map at this time!r'   )r   rs   loggerinfor_   rJ   rK   r   warningget_default_vocab_listgetattrrU   rL   rM   rN   s     r2   rM   EsmConfig.__post_init__   s      ""*ab&3o#D//66&3&Jd6I6I&J#&ij"8":"&D"DO*wt7J7JL^`e/f/fnoo''r1   )rs   r   ),r(   r)   r*   r+   r,   
model_typer_   rZ   rt   r-   r.   ru   rv   rw   rx   ry   rz   r{   r/   r|   r}   r~   r   r   r   rm   r   r[   r   r   r   rs   rK   r   listtupler   r   r   r   r   rM   r0   r\   r]   s   @r2   rp   rp      s    D J#]3K!Jd
! $M3:$#L#*#Ks!!!s!(++14 %$,4#'S'J#u##(NEDL(*4S4Z4It)-4$;-!&M4$;&$)dTk)26ND=(4/659JS	E#s(O+d29#Jt#',, $$#L#*#+,L#S	/D(,( (r1   rp   c                      g)N)!z<cls>z<pad>z<eos>z<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OrT   -z<null_1>z<mask>r'   r'   r1   r2   r   r      s    "r1   N)r,   typingr   huggingface_hub.dataclassesr   configuration_utilsr   utilsr   r   utils.type_validatorsr	   r
   
get_loggerr(   r   r   r4   r_   rp   r   __all__r'   r1   r2   <module>r      s      . 3 , > 
		H	% 1, 1 1h /" / /d ($ ( (, ,-R(  R(  .R(j#L -r1   