






'''simple docstring'''
import torch
import torch.nn as nn
from transformers.modeling_utils import ModuleUtilsMixin
from transformers.models.ta.modeling_ta import (
    TaBlock,
    TaConfig,
    TaLayerNorm,
)

from ...configuration_utils import ConfigMixin, register_to_config
from ...models import ModelMixin



class _A  (    __SCREAMING_SNAKE_CASE	,				__SCREAMING_SNAKE_CASE	,				__SCREAMING_SNAKE_CASE    ):





		@register_to_config
		def __init__(     self ,       __UpperCAmelCase ,       __UpperCAmelCase ,       __UpperCAmelCase ,       __UpperCAmelCase ,       __UpperCAmelCase ,       __UpperCAmelCase ,       __UpperCAmelCase ,       __UpperCAmelCase ,       __UpperCAmelCase ,       __UpperCAmelCase = False ,       )       ->     List[str]:

					'''simple docstring'''
					super().__init__()

					__UpperCAmelCase   :      Optional[Any]										=     nn.Linear(__UpperCAmelCase ,       __UpperCAmelCase ,       bias=__UpperCAmelCase				)

					__UpperCAmelCase   :      List[Any]										=     nn.Embedding(__UpperCAmelCase ,       __UpperCAmelCase				)
					__UpperCAmelCase   :      Any										=     False

					__UpperCAmelCase   :      Union[str, Any]										=     nn.Dropout(p=__UpperCAmelCase				)

					__UpperCAmelCase   :      int										=     TaConfig(
					    d_model=__UpperCAmelCase ,       num_heads=__UpperCAmelCase ,       d_kv=__UpperCAmelCase ,       d_ff=__UpperCAmelCase ,       feed_forward_proj=__UpperCAmelCase ,       dropout_rate=__UpperCAmelCase ,       is_decoder=__UpperCAmelCase ,       is_encoder_decoder=__UpperCAmelCase ,       )
					__UpperCAmelCase   :      Any										=     nn.ModuleList()
					for lyr_num in range(__UpperCAmelCase				):
								__UpperCAmelCase   :      str										=     TaBlock(__UpperCAmelCase				)
								self.encoders.append(__UpperCAmelCase				)

					__UpperCAmelCase   :      int										=     TaLayerNorm(__UpperCAmelCase				)
					__UpperCAmelCase   :      Union[str, Any]										=     nn.Dropout(p=__UpperCAmelCase				)





		def 							__A       (     self ,       __UpperCAmelCase ,       __UpperCAmelCase				)       ->     str:

					'''simple docstring'''
					__UpperCAmelCase   :      Any										=     self.input_proj(__UpperCAmelCase				)

					# terminal relative positional encodings
					__UpperCAmelCase   :      int										=     encoder_inputs.shape[1]
					__UpperCAmelCase   :      Dict										=     torch.arange(__UpperCAmelCase ,       device=encoder_inputs.device				)

					__UpperCAmelCase   :      Dict										=     encoder_inputs_mask.sum(-1				)
					__UpperCAmelCase   :      Union[str, Any]										=     torch.roll(input_positions.unsqueeze(0				) ,       tuple(seq_lens.tolist()				) ,       dims=0				)
					x += self.position_encoding(__UpperCAmelCase				)

					__UpperCAmelCase   :      Tuple										=     self.dropout_pre(__UpperCAmelCase				)

					# inverted the attention mask
					__UpperCAmelCase   :      List[Any]										=     encoder_inputs.size()
					__UpperCAmelCase   :      Dict										=     self.get_extended_attention_mask(__UpperCAmelCase ,       __UpperCAmelCase				)

					for lyr in self.encoders:
								__UpperCAmelCase   :      Union[str, Any]										=     lyr(__UpperCAmelCase ,       __UpperCAmelCase				)[0]
					__UpperCAmelCase   :      Any										=     self.layer_norm(__UpperCAmelCase				)

					return self.dropout_post(__UpperCAmelCase				), encoder_inputs_mask









'''simple docstring'''
from .chunk_utils import chunk_layer
from .data_transforms import make_atomaa_masks
from .feats import atomaa_to_atomaa, frames_and_literature_positions_to_atomaa_pos, torsion_angles_to_frames
from .loss import compute_predicted_aligned_error, compute_tm
from .protein import Protein as OFProtein
from .protein import to_pdb
from .rigid_utils import Rigid, Rotation
from .tensor_utils import dict_multimap, flatten_final_dims, permute_final_dims




