§
    ’j«  ã                   óD   — d Z ddlZddlmZ  G d„ dej        ¦  «        ZdS )zActivation modules.é    Nc                   óJ   ‡ — e Zd ZdZddˆ fd„Zdej        dej        fd„Zˆ xZS )	ÚAGLUaF  Unified activation function module from AGLU.

    This class implements a parameterized activation function with learnable parameters lambda and kappa, based on the
    AGLU (Adaptive Gated Linear Unit) approach.

    Attributes:
        act (nn.Softplus): Softplus activation function with negative beta.
        lambd (nn.Parameter): Learnable lambda parameter initialized with uniform distribution.
        kappa (nn.Parameter): Learnable kappa parameter initialized with uniform distribution.

    Methods:
        forward: Compute the forward pass of the Unified activation function.

    Examples:
        >>> import torch
        >>> m = AGLU()
        >>> input = torch.randn(2)
        >>> output = m(input)
        >>> print(output.shape)
        torch.Size([2])

    References:
        https://github.com/kostas1515/AGLU
    NÚreturnc           	      ó¨  •— t          ¦   «                              ¦   «          t          j        d¬¦  «        | _        t          j        t          j                             t          j	        d||¬¦  «        ¦  «        ¦  «        | _
        t          j        t          j                             t          j	        d||¬¦  «        ¦  «        ¦  «        | _        dS )zEInitialize the Unified activation function with learnable parameters.g      ð¿)Úbetaé   )ÚdeviceÚdtypeN)ÚsuperÚ__init__ÚnnÚSoftplusÚactÚ	ParameterÚinitÚuniform_ÚtorchÚemptyÚlambdÚkappa)Úselfr	   r
   Ú	__class__s      €úf/home/longshao/multi-rider-rag/.venv/lib/python3.11/site-packages/ultralytics/nn/modules/activation.pyr   zAGLU.__init__"   s—   ø€ å‰Œ×ÒÑÔÐÝ”; DÐ)Ñ)Ô)ˆŒÝ”\¥"¤'×"2Ò"2µ5´;¸qÈÐW\Ð3]Ñ3]Ô3]Ñ"^Ô"^Ñ_Ô_ˆŒ
Ý”\¥"¤'×"2Ò"2µ5´;¸qÈÐW\Ð3]Ñ3]Ô3]Ñ"^Ô"^Ñ_Ô_ˆŒ
ˆ
ˆ
ó    Úxc           	      óÌ   — t          j        | j        d¬¦  «        }t          j        d|z  |                      | j        |z  t          j        |¦  «        z
  ¦  «        z  ¦  «        S )a  Apply the Adaptive Gated Linear Unit (AGLU) activation function.

        This forward method implements the AGLU activation function with learnable parameters lambda and kappa. The
        function applies a transformation that adaptively combines linear and non-linear components.

        Args:
            x (torch.Tensor): Input tensor to apply the activation function to.

        Returns:
            (torch.Tensor): Output tensor after applying the AGLU activation function, with the same shape as the input.
        g-Cëâ6?)Úminr   )r   Úclampr   Úexpr   r   Úlog)r   r   Úlams      r   ÚforwardzAGLU.forward)   sR   € õ Œk˜$œ*¨&Ð1Ñ1Ô1ˆÝŒy˜!˜c™' T§X¢X¨t¬z¸A©~ÅÄÈ3ÁÄÑ.OÑ%PÔ%PÑPÑQÔQÐQr   )NN)r   N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   ÚTensorr"   Ú__classcell__)r   s   @r   r   r      sƒ   ø€ € € € € ðð ð2`ð `ð `ð `ð `ð `ð `ðR˜œð R¨%¬,ð Rð Rð Rð Rð Rð Rð Rð Rr   r   )r&   r   Útorch.nnr   ÚModuler   © r   r   ú<module>r,      sf   ðà Ð à €€€Ø Ð Ð Ð Ð Ð ð.Rð .Rð .Rð .Rð .Rˆ2Œ9ñ .Rô .Rð .Rð .Rð .Rr   