o
     ¢iµ  ã                   @   sd   d dl mZ d dlmZmZ ddlmZ ddlmZ ddl	mZm
Z
 ddlmZ G d	d
„ d
eƒZdS )é    )ÚTensor)ÚModuleÚ
ModuleListé   )ÚAttentionMask)ÚBertAttentionConfig)r   ÚBertEncoderLayeré   )ÚAlbertLayerConfigc                       s@   e Zd Zdededdf‡ fdd„Zdededefd	d
„Z‡  Z	S )ÚAlbertLayerGroupÚlayer_configÚattention_configÚreturnNc                    s.   t ƒ  ¡  t‡ ‡fdd„tˆjƒD ƒƒ| _d S )Nc                    s   g | ]}t ˆˆ ƒ‘qS © )r   )Ú.0Ú_©r   r   r   úb/home/ubuntu/.local/lib/python3.10/site-packages/curated_transformers/models/albert/layer_group.pyÚ
<listcomp>   s    ÿÿz-AlbertLayerGroup.__init__.<locals>.<listcomp>)ÚsuperÚ__init__r   ÚrangeÚinner_group_numÚgroup_layers)Úselfr   r   ©Ú	__class__r   r   r      s   
þ
ÿzAlbertLayerGroup.__init__ÚinputÚ	attn_maskc                 C   s   |}| j D ]}|||ƒ}q|S )zE
        Shapes:
            input - (batch, seq_len, width)
        )r   )r   r   r   Úlayer_outputÚlayerr   r   r   Úforward   s   
zAlbertLayerGroup.forward)
Ú__name__Ú
__module__Ú__qualname__r
   r   r   r   r   r!   Ú__classcell__r   r   r   r   r   
   s    ÿÿþr   N)Útorchr   Útorch.nnr   r   Ú	attentionr   Úbert.configr   Ú
bert.layerr   Úconfigr
   r   r   r   r   r   Ú<module>   s    