
    PiB                     n    d dl mZ d dlmZmZmZ d dlmZ d dlm	Z	 de
de
de
de
d	e
d
e
de
de
dede
fdZdS )    )nn)	T5EncoderT5EncoderLayerT5EncoderSelfAttention)FeedForward)RMSNorm	embed_dimmlp_dim	num_headshead_dim
num_layersrel_pos_num_bucketsrel_pos_max_dist
vocab_sizenorm_epsmax_seq_lenc
                    t          j        ||           }
t          j                    }t          |          D ]}t	          | ||t          j        | | d          t          j        | | d          t          j        | | d          t          j        | | d                    }t          t          j        | |d          t          j        || d          t          j        | |d          t          j                              }t          ||t          | |          t          | |                    }|
                    |           t          | |          }t          |
||||||	          S )aM  
    Builder for the T5 encoder.

    T5 paper: https://arxiv.org/abs/1910.10683

    Args:
        embed_dim (int): The model dimension.
        mlp_dim (int): The inner dimension of the feed forward layers.
        num_heads (int): The number of attention heads.
        head_dim (int): The dimension of the attention heads (should equal `embed_dim // num_heads`)
        num_layers (int): Number of encoder layers.
        rel_pos_num_buckets (int): Number of discrete buckets to divide the relative positions into.
            See: :class:`~torchtune.models.t5._encoder.T5EncoderRelativePositionBias`
        rel_pos_max_dist (int): Maximum distance for relative positions.
            Distances beyond this are grouped into the last bucket.
            See: :class:`~torchtune.models.t5._encoder.T5EncoderRelativePositionBias`
        vocab_size (int): Vocab size of the model's tokenizer.
        norm_eps (float): Small value added to denominator for numerical stability.
        max_seq_len (int): The maximum sequence length (context length) of the model.

    Returns:
        T5Encoder
    F)bias)r	   r   r   q_projk_projv_projoutput_proj)	gate_proj	down_projup_proj
activation)eps)attnmlpsa_normmlp_norm)token_embeddinglayers
final_normr   r   r   r   )r   	Embedding
ModuleListranger   Linearr   GELUr   r   appendr   )r	   r
   r   r   r   r   r   r   r   r   r"   r#   _r   r   layerr$   s                    {/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/torchtune/models/t5/_component_builders.py
t5_encoderr.      s   F l:y99O]__F:  %9Y	>>>9Y	>>>9Y	>>>	)YUCCC
 
 
 i	7???i???Iiu===wyy	
 
 
 I8444YH555	
 
 
 	e111J'/)       N)torchr   torchtune.models.t5._encoderr   r   r   torchtune.modules.feed_forwardr   torchtune.modules.rms_normr   intfloatr.    r/   r-   <module>r7      s                  
 7 6 6 6 6 6 . . . . . .JJJ J 	J
 J J J J J J J J J J Jr/   