
    Pi                     L    d dl mZ d dlZd dlmZ  G d dej                  ZdS )    )OptionalN)nnc            	            e Zd ZdZd ej                    ddej        dej        deej                 dej        f fdZd	e	j
        d
e	j
        fdZ xZS )FeedForwarda  This class implements the feed-forward network derived from Llama2.

    Args:
        gate_proj (nn.Module): Projection from input dim to hidden dim, fed through activation
            and multiplied by up_proj.
        down_proj (nn.Module): Final projection to output dim.
        up_proj (Optional[nn.Module]): Projection from input dim to hidden dim, multiplied by
            activation(gate_proj).
        activation (nn.Module): Activation function to use. Default is nn.SiLU().
    N)up_proj
activation	gate_proj	down_projr   r   c                    t                                                       || _        || _        || _        || _        d S )N)super__init__w1w2w3r   )selfr	   r
   r   r   	__class__s        r/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/torchtune/modules/feed_forward.pyr   zFeedForward.__init__   s;     	$    xreturnc                     |                      |                     |                    }| j        ||                     |          z  }|                     |          }|S )ad  
        Args:
            x (torch.Tensor): input tensor with shape ``(..., in_dim)``, where ``in_dim`` is the
                input dimension of both ``gate_proj`` and ``up_proj``.

        Returns:
            torch.Tensor: output tensor with shape ``(..., out_dim)``, where ``out_dim`` is the                 output dimension of ``down_proj``.
        )r   r   r   r   )r   r   hs      r   forwardzFeedForward.forward(   sN     OODGGAJJ''7DGGAJJAGGAJJr   )__name__
__module____qualname____doc__r   SiLUModuler   r   torchTensorr   __classcell__)r   s   @r   r   r      s        	 	  (, '		% % % 9% 9	%
 ")$% I% % % % % % %,        r   r   )typingr   r    r   r   r    r   r   <module>r%      sj                ( ( ( ( (") ( ( ( ( (r   