o
    ©Ì³iâ  ã                   @   s*   d dl Z d dl mZ G dd„ dejƒZdS )é    N)Únnc                       s8   e Zd ZdZd	‡ fdd„Zdejdejfdd„Z‡  ZS )
ÚTanhGatez8Implements a basic learnable gate to scale layer outputsÚreturnNc                    s    t ƒ  ¡  t t d¡¡| _d S )Né   )ÚsuperÚ__init__r   Ú	ParameterÚtorchÚzerosÚscale)Úself©Ú	__class__© úO/home/ubuntu/.local/lib/python3.10/site-packages/torchtune/modules/tanh_gate.pyr      s   
zTanhGate.__init__Úxc                 C   s   || j  ¡  S )z³
        Args:
            x (torch.Tensor): input tensor to gate

        Returns:
            torch.Tensor: The output tensor after gating. Has the same shape as ``x``.
        )r   Útanh)r   r   r   r   r   Úforward   s   zTanhGate.forward)r   N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r	   ÚTensorr   Ú__classcell__r   r   r   r   r      s    r   )r	   r   ÚModuler   r   r   r   r   Ú<module>   s   