a
    Ž¥»a¶¥  ã                   @   sD  d dl Z d dlmZmZ d dlZd dlmZ 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	d
lmZ G dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd „ d eƒZG d!d"„ d"eƒZG d#d$„ d$eƒZG d%d&„ d&eƒZ G d'd(„ d(eƒZ!G d)d*„ d*eƒZ"G d+d,„ d,eƒZ#G d-d.„ d.eƒZ$G d/d0„ d0eƒZ%G d1d2„ d2eƒZ&G d3d4„ d4eƒZ'G d5d6„ d6eƒZ(G d7d8„ d8eƒZ)G d9d:„ d:eƒZ*G d;d<„ d<eƒZ+G d=d>„ d>eƒZ,G d?d@„ d@eƒZ-G dAdB„ dBeƒZ.G dCdD„ dDeƒZ/dS )Eé    N)ÚOptionalÚTuple)ÚTensoré   )ÚNonDynamicallyQuantizableLinear)Ú	constant_Úxavier_normal_Úxavier_uniform_)Ú	Parameter)ÚModuleé   )Ú
functionalc                       sh   e Zd ZU dZg d¢Zeed< eed< eed< deeeddœ‡ fd	d
„Ze	e	dœdd„Z
dd„ Z‡  ZS )Ú	Thresholda§  Thresholds each element of the input Tensor.

    Threshold is defined as:

    .. math::
        y =
        \begin{cases}
        x, &\text{ if } x > \text{threshold} \\
        \text{value}, &\text{ otherwise }
        \end{cases}

    Args:
        threshold: The value to threshold at
        value: The value to replace with
        inplace: can optionally do the operation in-place. Default: ``False``

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    Examples::

        >>> m = nn.Threshold(0.1, 20)
        >>> input = torch.randn(2)
        >>> output = m(input)
    )Ú	thresholdÚvalueÚinplacer   r   r   FN)r   r   r   Úreturnc                    s$   t t| ƒ ¡  || _|| _|| _d S ©N)Úsuperr   Ú__init__r   r   r   )Úselfr   r   r   ©Ú	__class__© úU/home/yuhw/wc/pochoir/venv/lib/python3.9/site-packages/torch/nn/modules/activation.pyr   .   s    zThreshold.__init__©Úinputr   c                 C   s   t  || j| j| j¡S r   )ÚFr   r   r   ©r   r   r   r   r   Úforward5   s    zThreshold.forwardc                 C   s    | j r
dnd}d | j| j|¡S )Nú, inplace=TrueÚ zthreshold={}, value={}{})r   Úformatr   r   ©r   Zinplace_strr   r   r   Ú
extra_repr8   s    
ÿzThreshold.extra_repr)F©Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__constants__ÚfloatÚ__annotations__Úboolr   r   r   r$   Ú__classcell__r   r   r   r   r      s   
r   c                       sV   e Zd ZU dZdgZeed< dedœ‡ fdd„Zeedœdd	„Z	e
d
œdd„Z‡  ZS )ÚReLUaÁ  Applies the rectified linear unit function element-wise:

    :math:`\text{ReLU}(x) = (x)^+ = \max(0, x)`

    Args:
        inplace: can optionally do the operation in-place. Default: ``False``

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    .. image:: ../scripts/activation_images/ReLU.png

    Examples::

        >>> m = nn.ReLU()
        >>> input = torch.randn(2)
        >>> output = m(input)


      An implementation of CReLU - https://arxiv.org/abs/1603.05201

        >>> m = nn.ReLU()
        >>> input = torch.randn(2).unsqueeze(0)
        >>> output = torch.cat((m(input),m(-input)))
    r   F©r   c                    s   t t| ƒ ¡  || _d S r   )r   r/   r   r   ©r   r   r   r   r   r   ]   s    zReLU.__init__r   c                 C   s   t j|| jd�S ©Nr0   )r   Zrelur   r   r   r   r   r   a   s    zReLU.forward©r   c                 C   s   | j r
dnd}|S ©Nzinplace=Truer!   r0   r#   r   r   r   r$   d   s    zReLU.extra_repr)F©r&   r'   r(   r)   r*   r-   r,   r   r   r   Ústrr$   r.   r   r   r   r   r/   ?   s   
r/   c                       sf   e Zd ZU dZg d¢Zeed< eed< eed< deeedœ‡ fd	d
„Ze	e	dœdd„Z
dd„ Z‡  ZS )ÚRReLUaª  Applies the randomized leaky rectified liner unit function, element-wise,
    as described in the paper:

    `Empirical Evaluation of Rectified Activations in Convolutional Network`_.

    The function is defined as:

    .. math::
        \text{RReLU}(x) =
        \begin{cases}
            x & \text{if } x \geq 0 \\
            ax & \text{ otherwise }
        \end{cases}

    where :math:`a` is randomly sampled from uniform distribution
    :math:`\mathcal{U}(\text{lower}, \text{upper})`.

     See: https://arxiv.org/pdf/1505.00853.pdf

    Args:
        lower: lower bound of the uniform distribution. Default: :math:`\frac{1}{8}`
        upper: upper bound of the uniform distribution. Default: :math:`\frac{1}{3}`
        inplace: can optionally do the operation in-place. Default: ``False``

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    Examples::

        >>> m = nn.RReLU(0.1, 0.3)
        >>> input = torch.randn(2)
        >>> output = m(input)

    .. _`Empirical Evaluation of Rectified Activations in Convolutional Network`:
        https://arxiv.org/abs/1505.00853
    )ÚlowerÚupperr   r8   r9   r   ç      À?çUUUUUUÕ?Fc                    s$   t t| ƒ ¡  || _|| _|| _d S r   )r   r7   r   r8   r9   r   )r   r8   r9   r   r   r   r   r   •   s    zRReLU.__init__r   c                 C   s   t  || j| j| j| j¡S r   )r   Zrrelur8   r9   Útrainingr   r   r   r   r   r       s    zRReLU.forwardc                 C   s    | j r
dnd}d | j| j|¡S )Nr    r!   zlower={}, upper={}{})r   r"   r8   r9   r#   r   r   r   r$   £   s    zRReLU.extra_repr)r:   r;   Fr%   r   r   r   r   r7   i   s   
%   üür7   c                       sz   e Zd ZU dZg d¢Zeed< eed< eed< deeeee ee d	d
œ‡ fdd„Z	e
e
dœdd„Zedœdd„Z‡  ZS )ÚHardtanha/  Applies the HardTanh function element-wise

    HardTanh is defined as:

    .. math::
        \text{HardTanh}(x) = \begin{cases}
            1 & \text{ if } x > 1 \\
            -1 & \text{ if } x < -1 \\
            x & \text{ otherwise } \\
        \end{cases}

    The range of the linear region :math:`[-1, 1]` can be adjusted using
    :attr:`min_val` and :attr:`max_val`.

    Args:
        min_val: minimum value of the linear region range. Default: -1
        max_val: maximum value of the linear region range. Default: 1
        inplace: can optionally do the operation in-place. Default: ``False``

    Keyword arguments :attr:`min_value` and :attr:`max_value`
    have been deprecated in favor of :attr:`min_val` and :attr:`max_val`.

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    .. image:: ../scripts/activation_images/Hardtanh.png

    Examples::

        >>> m = nn.Hardtanh(-2, 2)
        >>> input = torch.randn(2)
        >>> output = m(input)
    )Úmin_valÚmax_valr   r>   r?   r   ç      ð¿ç      ð?FN)r>   r?   r   Ú	min_valueÚ	max_valuer   c                    s`   t t| ƒ ¡  |d ur$t d¡ |}|d ur:t d¡ |}|| _|| _|| _| j| jks\J ‚d S )Nz>keyword argument min_value is deprecated and rename to min_valz>keyword argument max_value is deprecated and rename to max_val)r   r=   r   ÚwarningsÚwarnr>   r?   r   )r   r>   r?   r   rB   rC   r   r   r   r   Ñ   s    

zHardtanh.__init__r   c                 C   s   t  || j| j| j¡S r   )r   Zhardtanhr>   r?   r   r   r   r   r   r   æ   s    zHardtanh.forwardr3   c                 C   s    | j r
dnd}d | j| j|¡S )Nr    r!   zmin_val={}, max_val={}{})r   r"   r>   r?   r#   r   r   r   r$   é   s    
ÿzHardtanh.extra_repr)r@   rA   FNN)r&   r'   r(   r)   r*   r+   r,   r-   r   r   r   r   r6   r$   r.   r   r   r   r   r=   ¨   s(   
"     úùr=   c                       s6   e Zd ZdZd	edœ‡ fdd„Zedœdd„Z‡  ZS )
ÚReLU6aò  Applies the element-wise function:

    .. math::
        \text{ReLU6}(x) = \min(\max(0,x), 6)

    Args:
        inplace: can optionally do the operation in-place. Default: ``False``

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    .. image:: ../scripts/activation_images/ReLU6.png

    Examples::

        >>> m = nn.ReLU6()
        >>> input = torch.randn(2)
        >>> output = m(input)
    Fr0   c                    s   t t| ƒ dd|¡ d S )Nç        g      @)r   rF   r   r1   r   r   r   r     s    zReLU6.__init__r3   c                 C   s   | j r
dnd}|S r4   r0   r#   r   r   r   r$   	  s    zReLU6.extra_repr)F)	r&   r'   r(   r)   r-   r   r6   r$   r.   r   r   r   r   rF   ð   s   rF   c                   @   s    e Zd ZdZeedœdd„ZdS )ÚSigmoida°  Applies the element-wise function:

    .. math::
        \text{Sigmoid}(x) = \sigma(x) = \frac{1}{1 + \exp(-x)}


    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    .. image:: ../scripts/activation_images/Sigmoid.png

    Examples::

        >>> m = nn.Sigmoid()
        >>> input = torch.randn(2)
        >>> output = m(input)
    r   c                 C   s
   t  |¡S r   )ÚtorchZsigmoidr   r   r   r   r   "  s    zSigmoid.forwardN©r&   r'   r(   r)   r   r   r   r   r   r   rH     s   rH   c                       sJ   e Zd ZU dZdgZeed< deddœ‡ fdd„Zeedœd	d
„Z	‡  Z
S )ÚHardsigmoidaS  Applies the element-wise function:

    .. math::
        \text{Hardsigmoid}(x) = \begin{cases}
            0 & \text{if~} x \le -3, \\
            1 & \text{if~} x \ge +3, \\
            x / 6 + 1 / 2 & \text{otherwise}
        \end{cases}

    Args:
        inplace: can optionally do the operation in-place. Default: ``False``

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    Examples::

        >>> m = nn.Hardsigmoid()
        >>> input = torch.randn(2)
        >>> output = m(input)
    r   FN©r   r   c                    s   t t| ƒ ¡  || _d S r   )r   rK   r   r   r1   r   r   r   r   A  s    zHardsigmoid.__init__r   c                 C   s   t  || j¡S r   )r   Zhardsigmoidr   r   r   r   r   r   E  s    zHardsigmoid.forward)F©r&   r'   r(   r)   r*   r-   r,   r   r   r   r.   r   r   r   r   rK   &  s
   
rK   c                   @   s    e Zd ZdZeedœdd„ZdS )ÚTanha½  Applies the element-wise function:

    .. math::
        \text{Tanh}(x) = \tanh(x) = \frac{\exp(x) - \exp(-x)} {\exp(x) + \exp(-x)}

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    .. image:: ../scripts/activation_images/Tanh.png

    Examples::

        >>> m = nn.Tanh()
        >>> input = torch.randn(2)
        >>> output = m(input)
    r   c                 C   s
   t  |¡S r   )rI   Útanhr   r   r   r   r   \  s    zTanh.forwardNrJ   r   r   r   r   rN   I  s   rN   c                       sV   e Zd ZU dZdgZeed< dedœ‡ fdd„Zeedœdd	„Z	e
d
œdd„Z‡  ZS )ÚSiLUaÅ  Applies the Sigmoid Linear Unit (SiLU) function, element-wise.
    The SiLU function is also known as the swish function.

    .. math::
        \text{silu}(x) = x * \sigma(x), \text{where } \sigma(x) \text{ is the logistic sigmoid.}

    .. note::
        See `Gaussian Error Linear Units (GELUs) <https://arxiv.org/abs/1606.08415>`_
        where the SiLU (Sigmoid Linear Unit) was originally coined, and see
        `Sigmoid-Weighted Linear Units for Neural Network Function Approximation
        in Reinforcement Learning <https://arxiv.org/abs/1702.03118>`_ and `Swish:
        a Self-Gated Activation Function <https://arxiv.org/abs/1710.05941v1>`_
        where the SiLU was experimented with later.

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    Examples::

        >>> m = nn.SiLU()
        >>> input = torch.randn(2)
        >>> output = m(input)
    r   Fr0   c                    s   t t| ƒ ¡  || _d S r   )r   rP   r   r   r1   r   r   r   r   {  s    zSiLU.__init__r   c                 C   s   t j|| jd�S r2   )r   Zsilur   r   r   r   r   r     s    zSiLU.forwardr3   c                 C   s   | j r
dnd}|S r4   r0   r#   r   r   r   r$   ‚  s    zSiLU.extra_repr)Fr5   r   r   r   r   rP   _  s   
rP   c                       sV   e Zd ZU dZdgZeed< dedœ‡ fdd„Zeedœdd	„Z	e
d
œdd„Z‡  ZS )ÚMishaA  Applies the Mish function, element-wise.
    Mish: A Self Regularized Non-Monotonic Neural Activation Function.

    .. math::
        \text{Mish}(x) = x * \text{Tanh}(\text{Softplus}(x))

    .. note::
        See `Mish: A Self Regularized Non-Monotonic Neural Activation Function <https://arxiv.org/abs/1908.08681>`_

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    Examples::

        >>> m = nn.Mish()
        >>> input = torch.randn(2)
        >>> output = m(input)
    r   Fr0   c                    s   t t| ƒ ¡  || _d S r   )r   rQ   r   r   r1   r   r   r   r   �  s    zMish.__init__r   c                 C   s   t j|| jd�S r2   )r   Zmishr   r   r   r   r   r   ¡  s    zMish.forwardr3   c                 C   s   | j r
dnd}|S r4   r0   r#   r   r   r   r$   ¤  s    zMish.extra_repr)Fr5   r   r   r   r   rQ   †  s   
rQ   c                       sJ   e Zd ZU dZdgZeed< deddœ‡ fdd„Zeedœd	d
„Z	‡  Z
S )Ú	Hardswishaì  Applies the hardswish function, element-wise, as described in the paper:

    `Searching for MobileNetV3`_.

    .. math::
        \text{Hardswish}(x) = \begin{cases}
            0 & \text{if~} x \le -3, \\
            x & \text{if~} x \ge +3, \\
            x \cdot (x + 3) /6 & \text{otherwise}
        \end{cases}

    Args:
        inplace: can optionally do the operation in-place. Default: ``False``

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    Examples::

        >>> m = nn.Hardswish()
        >>> input = torch.randn(2)
        >>> output = m(input)

    .. _`Searching for MobileNetV3`:
        https://arxiv.org/abs/1905.02244
    r   FNrL   c                    s   t t| ƒ ¡  || _d S r   )r   rR   r   r   r1   r   r   r   r   È  s    zHardswish.__init__r   c                 C   s   t  || j¡S r   )r   Z	hardswishr   r   r   r   r   r   Ì  s    zHardswish.forward)FrM   r   r   r   r   rR   ¨  s
   
rR   c                       sd   e Zd ZU dZddgZeed< eed< deeddœ‡ fdd	„Ze	e	d
œdd„Z
edœdd„Z‡  ZS )ÚELUa¡  Applies the element-wise function:

    .. math::
        \text{ELU}(x) = \begin{cases}
        x, & \text{ if } x > 0\\
        \alpha * (\exp(x) - 1), & \text{ if } x \leq 0
        \end{cases}

    Args:
        alpha: the :math:`\alpha` value for the ELU formulation. Default: 1.0
        inplace: can optionally do the operation in-place. Default: ``False``

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    .. image:: ../scripts/activation_images/ELU.png

    Examples::

        >>> m = nn.ELU()
        >>> input = torch.randn(2)
        >>> output = m(input)
    Úalphar   rA   FN©rT   r   r   c                    s   t t| ƒ ¡  || _|| _d S r   )r   rS   r   rT   r   ©r   rT   r   r   r   r   r   í  s    zELU.__init__r   c                 C   s   t  || j| j¡S r   )r   ZelurT   r   r   r   r   r   r   ò  s    zELU.forwardr3   c                 C   s   | j r
dnd}d | j|¡S ©Nr    r!   z
alpha={}{}©r   r"   rT   r#   r   r   r   r$   õ  s    zELU.extra_repr)rA   F©r&   r'   r(   r)   r*   r+   r,   r-   r   r   r   r6   r$   r.   r   r   r   r   rS   Ð  s   
rS   c                       sd   e Zd ZU dZddgZeed< eed< deeddœ‡ fdd	„Ze	e	d
œdd„Z
edœdd„Z‡  ZS )ÚCELUa.  Applies the element-wise function:

    .. math::
        \text{CELU}(x) = \max(0,x) + \min(0, \alpha * (\exp(x/\alpha) - 1))

    More details can be found in the paper `Continuously Differentiable Exponential Linear Units`_ .

    Args:
        alpha: the :math:`\alpha` value for the CELU formulation. Default: 1.0
        inplace: can optionally do the operation in-place. Default: ``False``

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    .. image:: ../scripts/activation_images/CELU.png

    Examples::

        >>> m = nn.CELU()
        >>> input = torch.randn(2)
        >>> output = m(input)

    .. _`Continuously Differentiable Exponential Linear Units`:
        https://arxiv.org/abs/1704.07483
    rT   r   rA   FNrU   c                    s   t t| ƒ ¡  || _|| _d S r   )r   rZ   r   rT   r   rV   r   r   r   r     s    zCELU.__init__r   c                 C   s   t  || j| j¡S r   )r   ZcelurT   r   r   r   r   r   r     s    zCELU.forwardr3   c                 C   s   | j r
dnd}d | j|¡S rW   rX   r#   r   r   r   r$   !  s    zCELU.extra_repr)rA   FrY   r   r   r   r   rZ   ú  s   
rZ   c                       sX   e Zd ZU dZdgZeed< deddœ‡ fdd„Zeedœd	d
„Z	e
dœdd„Z‡  ZS )ÚSELUay  Applied element-wise, as:

    .. math::
        \text{SELU}(x) = \text{scale} * (\max(0,x) + \min(0, \alpha * (\exp(x) - 1)))

    with :math:`\alpha = 1.6732632423543772848170429916717` and
    :math:`\text{scale} = 1.0507009873554804934193349852946`.

    .. warning::
        When using ``kaiming_normal`` or ``kaiming_normal_`` for initialisation,
        ``nonlinearity='linear'`` should be used instead of ``nonlinearity='selu'``
        in order to get `Self-Normalizing Neural Networks`_.
        See :func:`torch.nn.init.calculate_gain` for more information.

    More details can be found in the paper `Self-Normalizing Neural Networks`_ .

    Args:
        inplace (bool, optional): can optionally do the operation in-place. Default: ``False``

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    .. image:: ../scripts/activation_images/SELU.png

    Examples::

        >>> m = nn.SELU()
        >>> input = torch.randn(2)
        >>> output = m(input)

    .. _Self-Normalizing Neural Networks: https://arxiv.org/abs/1706.02515
    r   FNrL   c                    s   t t| ƒ ¡  || _d S r   )r   r[   r   r   r1   r   r   r   r   K  s    zSELU.__init__r   c                 C   s   t  || j¡S r   )r   Zselur   r   r   r   r   r   O  s    zSELU.forwardr3   c                 C   s   | j r
dnd}|S r4   r0   r#   r   r   r   r$   R  s    zSELU.extra_repr)Fr5   r   r   r   r   r[   &  s   
!r[   c                       sX   e Zd ZU dZdgZeed< deddœ‡ fdd„Zeedœd	d
„Z	e
dœdd„Z‡  ZS )ÚGLUa3  Applies the gated linear unit function
    :math:`{GLU}(a, b)= a \otimes \sigma(b)` where :math:`a` is the first half
    of the input matrices and :math:`b` is the second half.

    Args:
        dim (int): the dimension on which to split the input. Default: -1

    Shape:
        - Input: :math:`(\ast_1, N, \ast_2)` where `*` means, any number of additional
          dimensions
        - Output: :math:`(\ast_1, M, \ast_2)` where :math:`M=N/2`

    Examples::

        >>> m = nn.GLU()
        >>> input = torch.randn(4, 2)
        >>> output = m(input)
    ÚdiméÿÿÿÿN©r]   r   c                    s   t t| ƒ ¡  || _d S r   )r   r\   r   r]   ©r   r]   r   r   r   r   m  s    zGLU.__init__r   c                 C   s   t  || j¡S r   )r   Zglur]   r   r   r   r   r   q  s    zGLU.forwardr3   c                 C   s   d  | j¡S )Nzdim={}©r"   r]   ©r   r   r   r   r$   t  s    zGLU.extra_repr)r^   ©r&   r'   r(   r)   r*   Úintr,   r   r   r   r6   r$   r.   r   r   r   r   r\   W  s   
r\   c                   @   s    e Zd ZdZeedœdd„ZdS )ÚGELUaô  Applies the Gaussian Error Linear Units function:

    .. math:: \text{GELU}(x) = x * \Phi(x)

    where :math:`\Phi(x)` is the Cumulative Distribution Function for Gaussian Distribution.

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    .. image:: ../scripts/activation_images/GELU.png

    Examples::

        >>> m = nn.GELU()
        >>> input = torch.randn(2)
        >>> output = m(input)
    r   c                 C   s
   t  |¡S r   )r   Zgelur   r   r   r   r   ‹  s    zGELU.forwardNrJ   r   r   r   r   re   x  s   re   c                       sX   e Zd ZU dZdgZeed< deddœ‡ fdd„Zeedœd	d
„Z	e
dœdd„Z‡  ZS )Ú
Hardshrinka   Applies the hard shrinkage function element-wise:

    .. math::
        \text{HardShrink}(x) =
        \begin{cases}
        x, & \text{ if } x > \lambda \\
        x, & \text{ if } x < -\lambda \\
        0, & \text{ otherwise }
        \end{cases}

    Args:
        lambd: the :math:`\lambda` value for the Hardshrink formulation. Default: 0.5

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    .. image:: ../scripts/activation_images/Hardshrink.png

    Examples::

        >>> m = nn.Hardshrink()
        >>> input = torch.randn(2)
        >>> output = m(input)
    Úlambdç      à?N©rg   r   c                    s   t t| ƒ ¡  || _d S r   )r   rf   r   rg   ©r   rg   r   r   r   r   ¬  s    zHardshrink.__init__r   c                 C   s   t  || j¡S r   )r   Z
hardshrinkrg   r   r   r   r   r   °  s    zHardshrink.forwardr3   c                 C   s   d  | j¡S )Nz{})r"   rg   rb   r   r   r   r$   ³  s    zHardshrink.extra_repr)rh   ©r&   r'   r(   r)   r*   r+   r,   r   r   r   r6   r$   r.   r   r   r   r   rf   �  s   
rf   c                       sd   e Zd ZU dZddgZeed< eed< deeddœ‡ fdd	„Ze	e	d
œdd„Z
edœdd„Z‡  ZS )Ú	LeakyReLUa?  Applies the element-wise function:

    .. math::
        \text{LeakyReLU}(x) = \max(0, x) + \text{negative\_slope} * \min(0, x)


    or

    .. math::
        \text{LeakyRELU}(x) =
        \begin{cases}
        x, & \text{ if } x \geq 0 \\
        \text{negative\_slope} \times x, & \text{ otherwise }
        \end{cases}

    Args:
        negative_slope: Controls the angle of the negative slope. Default: 1e-2
        inplace: can optionally do the operation in-place. Default: ``False``

    Shape:
        - Input: :math:`(*)` where `*` means, any number of additional
          dimensions
        - Output: :math:`(*)`, same shape as the input

    .. image:: ../scripts/activation_images/LeakyReLU.png

    Examples::

        >>> m = nn.LeakyReLU(0.1)
        >>> input = torch.randn(2)
        >>> output = m(input)
    r   Únegative_slopeç{®Gáz„?FN)rm   r   r   c                    s   t t| ƒ ¡  || _|| _d S r   )r   rl   r   rm   r   )r   rm   r   r   r   r   r   Ü  s    zLeakyReLU.__init__r   c                 C   s   t  || j| j¡S r   )r   Z
leaky_relurm   r   r   r   r   r   r   á  s    zLeakyReLU.forwardr3   c                 C   s   | j r
dnd}d | j|¡S )Nr    r!   znegative_slope={}{})r   r"   rm   r#   r   r   r   r$   ä  s    zLeakyReLU.extra_repr)rn   F)r&   r'   r(   r)   r*   r-   r,   r+   r   r   r   r6   r$   r.   r   r   r   r   rl   ·  s   
 rl   c                   @   s    e Zd ZdZeedœdd„ZdS )Ú
LogSigmoidaÀ  Applies the element-wise function:

    .. math::
        \text{LogSigmoid}(x) = \log\left(\frac{ 1 }{ 1 + \exp(-x)}\right)

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    .. image:: ../scripts/activation_images/LogSigmoid.png

    Examples::

        >>> m = nn.LogSigmoid()
        >>> input = torch.randn(2)
        >>> output = m(input)
    r   c                 C   s
   t  |¡S r   )r   Z
logsigmoidr   r   r   r   r   ü  s    zLogSigmoid.forwardNrJ   r   r   r   r   ro   é  s   ro   c                       sd   e Zd ZU dZddgZeed< eed< deeddœ‡ fdd	„Zeed
œdd„Z	e
dœdd„Z‡  ZS )ÚSoftplusap  Applies the element-wise function:

    .. math::
        \text{Softplus}(x) = \frac{1}{\beta} * \log(1 + \exp(\beta * x))

    SoftPlus is a smooth approximation to the ReLU function and can be used
    to constrain the output of a machine to always be positive.

    For numerical stability the implementation reverts to the linear function
    when :math:`input \times \beta > threshold`.

    Args:
        beta: the :math:`\beta` value for the Softplus formulation. Default: 1
        threshold: values above this revert to a linear function. Default: 20

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    .. image:: ../scripts/activation_images/Softplus.png

    Examples::

        >>> m = nn.Softplus()
        >>> input = torch.randn(2)
        >>> output = m(input)
    Úbetar   r   é   N)rq   r   r   c                    s   t t| ƒ ¡  || _|| _d S r   )r   rp   r   rq   r   )r   rq   r   r   r   r   r      s    zSoftplus.__init__r   c                 C   s   t  || j| j¡S r   )r   Zsoftplusrq   r   r   r   r   r   r   %  s    zSoftplus.forwardr3   c                 C   s   d  | j| j¡S )Nzbeta={}, threshold={})r"   rq   r   rb   r   r   r   r$   (  s    zSoftplus.extra_repr)r   rr   rc   r   r   r   r   rp      s   
rp   c                       sX   e Zd ZU dZdgZeed< deddœ‡ fdd„Zeedœd	d
„Z	e
dœdd„Z‡  ZS )Ú
SoftshrinkaÒ  Applies the soft shrinkage function elementwise:

    .. math::
        \text{SoftShrinkage}(x) =
        \begin{cases}
        x - \lambda, & \text{ if } x > \lambda \\
        x + \lambda, & \text{ if } x < -\lambda \\
        0, & \text{ otherwise }
        \end{cases}

    Args:
        lambd: the :math:`\lambda` (must be no less than zero) value for the Softshrink formulation. Default: 0.5

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    .. image:: ../scripts/activation_images/Softshrink.png

    Examples::

        >>> m = nn.Softshrink()
        >>> input = torch.randn(2)
        >>> output = m(input)
    rg   rh   Nri   c                    s   t t| ƒ ¡  || _d S r   )r   rs   r   rg   rj   r   r   r   r   I  s    zSoftshrink.__init__r   c                 C   s   t  || j¡S r   )r   Z
softshrinkrg   r   r   r   r   r   M  s    zSoftshrink.forwardr3   c                 C   s
   t | jƒS r   )r6   rg   rb   r   r   r   r$   P  s    zSoftshrink.extra_repr)rh   rk   r   r   r   r   rs   ,  s   
rs   c                       s�   e Zd ZU dZdgZeej ed< eej ed< ddd	œ‡ fd
d„Z	dd„ Z
‡ fdd„Zdeeeee eee eeee f dœdd„Z‡  ZS )ÚMultiheadAttentiona   Allows the model to jointly attend to information
    from different representation subspaces.
    See `Attention Is All You Need <https://arxiv.org/abs/1706.03762>`_.

    .. math::
        \text{MultiHead}(Q, K, V) = \text{Concat}(head_1,\dots,head_h)W^O

    where :math:`head_i = \text{Attention}(QW_i^Q, KW_i^K, VW_i^V)`.

    Args:
        embed_dim: Total dimension of the model.
        num_heads: Number of parallel attention heads. Note that ``embed_dim`` will be split
            across ``num_heads`` (i.e. each head will have dimension ``embed_dim // num_heads``).
        dropout: Dropout probability on ``attn_output_weights``. Default: ``0.0`` (no dropout).
        bias: If specified, adds bias to input / output projection layers. Default: ``True``.
        add_bias_kv: If specified, adds bias to the key and value sequences at dim=0. Default: ``False``.
        add_zero_attn: If specified, adds a new batch of zeros to the key and value sequences at dim=1.
            Default: ``False``.
        kdim: Total number of features for keys. Default: ``None`` (uses ``kdim=embed_dim``).
        vdim: Total number of features for values. Default: ``None`` (uses ``vdim=embed_dim``).
        batch_first: If ``True``, then the input and output tensors are provided
            as (batch, seq, feature). Default: ``False`` (seq, batch, feature).

    Examples::

        >>> multihead_attn = nn.MultiheadAttention(embed_dim, num_heads)
        >>> attn_output, attn_output_weights = multihead_attn(query, key, value)
    Úbatch_firstÚbias_kÚbias_vrG   TFNr3   c                    sê  |
|dœ}t t| ƒ ¡  || _|d ur*|n|| _|d ur<|n|| _| j|koT| j|k| _|| _|| _|	| _	|| | _
| j
| | jksŒJ dƒ‚| jdu rüttj||ffi |¤Žƒ| _ttj|| jffi |¤Žƒ| _ttj|| jffi |¤Žƒ| _|  dd ¡ nDttjd| |ffi |¤Žƒ| _|  dd ¡ |  dd ¡ |  dd ¡ |�rdttjd| fi |¤Žƒ| _n|  d	d ¡ t||fd
|i|¤Ž| _|�rÌttjdd|ffi |¤Žƒ| _ttjdd|ffi |¤Žƒ| _nd  | _| _|| _|  ¡  d S )N©ÚdeviceÚdtypez(embed_dim must be divisible by num_headsFÚin_proj_weighté   Úq_proj_weightÚk_proj_weightÚv_proj_weightÚin_proj_biasÚbiasr   )r   rt   r   Ú	embed_dimÚkdimÚvdimÚ_qkv_same_embed_dimÚ	num_headsÚdropoutru   Zhead_dimr
   rI   Úemptyr}   r~   r   Zregister_parameterr{   r€   r   Úout_projrv   rw   Úadd_zero_attnÚ_reset_parameters)r   r‚   r†   r‡   r�   Zadd_bias_kvrŠ   rƒ   r„   ru   ry   rz   Úfactory_kwargsr   r   r   r   u  s<    


  zMultiheadAttention.__init__c                 C   s€   | j rt| jƒ nt| jƒ t| jƒ t| jƒ | jd urTt| jdƒ t| jj	dƒ | j
d urht| j
ƒ | jd ur|t| jƒ d S )NrG   )r…   r	   r{   r}   r~   r   r€   r   r‰   r�   rv   r   rw   rb   r   r   r   r‹   Ÿ  s    






z$MultiheadAttention._reset_parametersc                    s$   d|vrd|d< t t| ƒ |¡ d S )Nr…   T)r   rt   Ú__setstate__©r   Ústater   r   r   r�   ¯  s    zMultiheadAttention.__setstate__)ÚqueryÚkeyr   Úkey_padding_maskÚneed_weightsÚ	attn_maskr   c           	      C   sì   | j r dd„ |||fD ƒ\}}}| js€tj|||| j| j| j| j| j| j	| j
| j| jj| jj| j|||d| j| j| jd�\}}nJtj|||| j| j| j| j| j| j	| j
| j| jj| jj| j|||d�\}}| j rà| dd¡|fS ||fS dS )	a\  
    Args:
        query: Query embeddings of shape :math:`(L, N, E_q)` when ``batch_first=False`` or :math:`(N, L, E_q)`
            when ``batch_first=True``, where :math:`L` is the target sequence length, :math:`N` is the batch size,
            and :math:`E_q` is the query embedding dimension ``embed_dim``. Queries are compared against
            key-value pairs to produce the output. See "Attention Is All You Need" for more details.
        key: Key embeddings of shape :math:`(S, N, E_k)` when ``batch_first=False`` or :math:`(N, S, E_k)` when
            ``batch_first=True``, where :math:`S` is the source sequence length, :math:`N` is the batch size, and
            :math:`E_k` is the key embedding dimension ``kdim``. See "Attention Is All You Need" for more details.
        value: Value embeddings of shape :math:`(S, N, E_v)` when ``batch_first=False`` or :math:`(N, S, E_v)` when
            ``batch_first=True``, where :math:`S` is the source sequence length, :math:`N` is the batch size, and
            :math:`E_v` is the value embedding dimension ``vdim``. See "Attention Is All You Need" for more details.
        key_padding_mask: If specified, a mask of shape :math:`(N, S)` indicating which elements within ``key``
            to ignore for the purpose of attention (i.e. treat as "padding"). Binary and byte masks are supported.
            For a binary mask, a ``True`` value indicates that the corresponding ``key`` value will be ignored for
            the purpose of attention. For a byte mask, a non-zero value indicates that the corresponding ``key``
            value will be ignored.
        need_weights: If specified, returns ``attn_output_weights`` in addition to ``attn_outputs``.
            Default: ``True``.
        attn_mask: If specified, a 2D or 3D mask preventing attention to certain positions. Must be of shape
            :math:`(L, S)` or :math:`(N\cdot\text{num\_heads}, L, S)`, where :math:`N` is the batch size,
            :math:`L` is the target sequence length, and :math:`S` is the source sequence length. A 2D mask will be
            broadcasted across the batch while a 3D mask allows for a different mask for each entry in the batch.
            Binary, byte, and float masks are supported. For a binary mask, a ``True`` value indicates that the
            corresponding position is not allowed to attend. For a byte mask, a non-zero value indicates that the
            corresponding position is not allowed to attend. For a float mask, the mask values will be added to
            the attention weight.

    Outputs:
        - **attn_output** - Attention outputs of shape :math:`(L, N, E)` when ``batch_first=False`` or
          :math:`(N, L, E)` when ``batch_first=True``, where :math:`L` is the target sequence length, :math:`N` is
          the batch size, and :math:`E` is the embedding dimension ``embed_dim``.
        - **attn_output_weights** - Attention output weights of shape :math:`(N, L, S)`, where :math:`N` is the batch
          size, :math:`L` is the target sequence length, and :math:`S` is the source sequence length. Only returned
          when ``need_weights=True``.
        c                 S   s   g | ]}|  d d¡‘qS )r   r   )Ú	transpose)Ú.0Úxr   r   r   Ú
<listcomp>Ý  ó    z.MultiheadAttention.forward.<locals>.<listcomp>T)r<   r’   r“   r”   Zuse_separate_proj_weightr}   r~   r   )r<   r’   r“   r”   r   r   N)ru   r…   r   Zmulti_head_attention_forwardr‚   r†   r{   r€   rv   rw   rŠ   r‡   r‰   Úweightr�   r<   r}   r~   r   r•   )	r   r�   r‘   r   r’   r“   r”   Zattn_outputZattn_output_weightsr   r   r   r   ¶  s4    &÷ù
zMultiheadAttention.forward)	rG   TFFNNFNN)NTN)r&   r'   r(   r)   r*   r   rI   r   r,   r   r‹   r�   r-   r   r   r.   r   r   r   r   rt   T  s    
  ÿÿ*  ÿÿrt   c                       sZ   e Zd ZU dZdgZeed< deeddœ‡ fdd„Ze	e	d	œd
d„Z
edœdd„Z‡  ZS )ÚPReLUaÏ  Applies the element-wise function:

    .. math::
        \text{PReLU}(x) = \max(0,x) + a * \min(0,x)

    or

    .. math::
        \text{PReLU}(x) =
        \begin{cases}
        x, & \text{ if } x \geq 0 \\
        ax, & \text{ otherwise }
        \end{cases}

    Here :math:`a` is a learnable parameter. When called without arguments, `nn.PReLU()` uses a single
    parameter :math:`a` across all input channels. If called with `nn.PReLU(nChannels)`,
    a separate :math:`a` is used for each input channel.


    .. note::
        weight decay should not be used when learning :math:`a` for good performance.

    .. note::
        Channel dim is the 2nd dim of input. When input has dims < 2, then there is
        no channel dim and the number of channels = 1.

    Args:
        num_parameters (int): number of :math:`a` to learn.
            Although it takes an int as input, there is only two values are legitimate:
            1, or the number of channels at input. Default: 1
        init (float): the initial value of :math:`a`. Default: 0.25

    Shape:
        - Input: :math:`( *)` where `*` means, any number of additional
          dimensions.
        - Output: :math:`(*)`, same shape as the input.

    Attributes:
        weight (Tensor): the learnable weights of shape (:attr:`num_parameters`).

    .. image:: ../scripts/activation_images/PReLU.png

    Examples::

        >>> m = nn.PReLU()
        >>> input = torch.randn(2)
        >>> output = m(input)
    Únum_parametersr   ç      Ð?N)rœ   Úinitr   c                    s@   ||dœ}|| _ tt| ƒ ¡  ttj|fi |¤Ž |¡ƒ| _d S )Nrx   )	rœ   r   r›   r   r
   rI   rˆ   Zfill_rš   )r   rœ   rž   ry   rz   rŒ   r   r   r   r   ,  s    
zPReLU.__init__r   c                 C   s   t  || j¡S r   )r   Zprelurš   r   r   r   r   r   3  s    zPReLU.forwardr3   c                 C   s   d  | j¡S )Nznum_parameters={})r"   rœ   rb   r   r   r   r$   6  s    zPReLU.extra_repr)r   r�   NN)r&   r'   r(   r)   r*   rd   r,   r+   r   r   r   r6   r$   r.   r   r   r   r   r›   ø  s   
0  ÿÿr›   c                   @   s    e Zd ZdZeedœdd„ZdS )ÚSoftsigna¢  Applies the element-wise function:

    .. math::
        \text{SoftSign}(x) = \frac{x}{ 1 + |x|}

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    .. image:: ../scripts/activation_images/Softsign.png

    Examples::

        >>> m = nn.Softsign()
        >>> input = torch.randn(2)
        >>> output = m(input)
    r   c                 C   s
   t  |¡S r   )r   Zsoftsignr   r   r   r   r   M  s    zSoftsign.forwardNrJ   r   r   r   r   rŸ   :  s   rŸ   c                   @   s    e Zd ZdZeedœdd„ZdS )Ú
Tanhshrinka¢  Applies the element-wise function:

    .. math::
        \text{Tanhshrink}(x) = x - \tanh(x)

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    .. image:: ../scripts/activation_images/Tanhshrink.png

    Examples::

        >>> m = nn.Tanhshrink()
        >>> input = torch.randn(2)
        >>> output = m(input)
    r   c                 C   s
   t  |¡S r   )r   Z
tanhshrinkr   r   r   r   r   d  s    zTanhshrink.forwardNrJ   r   r   r   r   r    Q  s   r    c                       sb   e Zd ZU dZdgZee ed< dee ddœ‡ fdd„Zdd„ Z	e
e
d	œd
d„Zdd„ Z‡  ZS )ÚSoftmina4  Applies the Softmin function to an n-dimensional input Tensor
    rescaling them so that the elements of the n-dimensional output Tensor
    lie in the range `[0, 1]` and sum to 1.

    Softmin is defined as:

    .. math::
        \text{Softmin}(x_{i}) = \frac{\exp(-x_i)}{\sum_j \exp(-x_j)}

    Shape:
        - Input: :math:`(*)` where `*` means, any number of additional
          dimensions
        - Output: :math:`(*)`, same shape as the input

    Args:
        dim (int): A dimension along which Softmin will be computed (so every slice
            along dim will sum to 1).

    Returns:
        a Tensor of the same dimension and shape as the input, with
        values in the range [0, 1]

    Examples::

        >>> m = nn.Softmin()
        >>> input = torch.randn(2, 3)
        >>> output = m(input)
    r]   Nr_   c                    s   t t| ƒ ¡  || _d S r   )r   r¡   r   r]   r`   r   r   r   r   ˆ  s    zSoftmin.__init__c                 C   s    | j  |¡ t| dƒsd | _d S ©Nr]   ©Ú__dict__ÚupdateÚhasattrr]   rŽ   r   r   r   r�   Œ  s    
zSoftmin.__setstate__r   c                 C   s   t j|| jdd�S ©Né   ©Z_stacklevel)r   Zsoftminr]   r   r   r   r   r   ‘  s    zSoftmin.forwardc                 C   s   dj | jd�S ©Nz	dim={dim})r]   ra   rb   r   r   r   r$   ”  s    zSoftmin.extra_repr)N©r&   r'   r(   r)   r*   r   rd   r,   r   r�   r   r   r$   r.   r   r   r   r   r¡   h  s   
r¡   c                       sh   e Zd ZU dZdgZee ed< dee ddœ‡ fdd„Zdd„ Z	e
e
d	œd
d„Zedœdd„Z‡  ZS )ÚSoftmaxa‚  Applies the Softmax function to an n-dimensional input Tensor
    rescaling them so that the elements of the n-dimensional output Tensor
    lie in the range [0,1] and sum to 1.

    Softmax is defined as:

    .. math::
        \text{Softmax}(x_{i}) = \frac{\exp(x_i)}{\sum_j \exp(x_j)}

    When the input Tensor is a sparse tensor then the unspecifed
    values are treated as ``-inf``.

    Shape:
        - Input: :math:`(*)` where `*` means, any number of additional
          dimensions
        - Output: :math:`(*)`, same shape as the input

    Returns:
        a Tensor of the same dimension and shape as the input with
        values in the range [0, 1]

    Args:
        dim (int): A dimension along which Softmax will be computed (so every slice
            along dim will sum to 1).

    .. note::
        This module doesn't work directly with NLLLoss,
        which expects the Log to be computed between the Softmax and itself.
        Use `LogSoftmax` instead (it's faster and has better numerical properties).

    Examples::

        >>> m = nn.Softmax(dim=1)
        >>> input = torch.randn(2, 3)
        >>> output = m(input)

    r]   Nr_   c                    s   t t| ƒ ¡  || _d S r   )r   r¬   r   r]   r`   r   r   r   r   À  s    zSoftmax.__init__c                 C   s    | j  |¡ t| dƒsd | _d S r¢   r£   rŽ   r   r   r   r�   Ä  s    
zSoftmax.__setstate__r   c                 C   s   t j|| jdd�S r§   )r   Úsoftmaxr]   r   r   r   r   r   É  s    zSoftmax.forwardr3   c                 C   s   dj | jd�S rª   ra   rb   r   r   r   r$   Ì  s    zSoftmax.extra_repr)N)r&   r'   r(   r)   r*   r   rd   r,   r   r�   r   r   r6   r$   r.   r   r   r   r   r¬   —  s   
%r¬   c                   @   s    e Zd ZdZeedœdd„ZdS )Ú	Softmax2da|  Applies SoftMax over features to each spatial location.

    When given an image of ``Channels x Height x Width``, it will
    apply `Softmax` to each location :math:`(Channels, h_i, w_j)`

    Shape:
        - Input: :math:`(N, C, H, W)` or :math:`(C, H, W)`.
        - Output: :math:`(N, C, H, W)` or :math:`(C, H, W)` (same shape as input)

    Returns:
        a Tensor of the same dimension and shape as the input with
        values in the range [0, 1]

    Examples::

        >>> m = nn.Softmax2d()
        >>> # you softmax over the 2nd dimension
        >>> input = torch.randn(2, 3, 12, 13)
        >>> output = m(input)
    r   c                 C   s0   |  ¡ dks |  ¡ dks J dƒ‚tj|ddd�S )Né   r|   z-Softmax2d requires a 3D or 4D tensor as inputéýÿÿÿr¨   r©   )r]   r   r­   r   r   r   r   r   æ  s     zSoftmax2d.forwardNrJ   r   r   r   r   r®   Ð  s   r®   c                       sb   e Zd ZU dZdgZee ed< dee ddœ‡ fdd„Zdd„ Z	e
e
d	œd
d„Zdd„ Z‡  ZS )Ú
LogSoftmaxa×  Applies the :math:`\log(\text{Softmax}(x))` function to an n-dimensional
    input Tensor. The LogSoftmax formulation can be simplified as:

    .. math::
        \text{LogSoftmax}(x_{i}) = \log\left(\frac{\exp(x_i) }{ \sum_j \exp(x_j)} \right)

    Shape:
        - Input: :math:`(*)` where `*` means, any number of additional
          dimensions
        - Output: :math:`(*)`, same shape as the input

    Args:
        dim (int): A dimension along which LogSoftmax will be computed.

    Returns:
        a Tensor of the same dimension and shape as the input with
        values in the range [-inf, 0)

    Examples::

        >>> m = nn.LogSoftmax()
        >>> input = torch.randn(2, 3)
        >>> output = m(input)
    r]   Nr_   c                    s   t t| ƒ ¡  || _d S r   )r   r±   r   r]   r`   r   r   r   r     s    zLogSoftmax.__init__c                 C   s    | j  |¡ t| dƒsd | _d S r¢   r£   rŽ   r   r   r   r�     s    
zLogSoftmax.__setstate__r   c                 C   s   t j|| jdd�S r§   )r   Zlog_softmaxr]   r   r   r   r   r     s    zLogSoftmax.forwardc                 C   s   dj | jd�S rª   ra   rb   r   r   r   r$     s    zLogSoftmax.extra_repr)Nr«   r   r   r   r   r±   ë  s   
r±   )0rD   Útypingr   r   rI   r   Zlinearr   Ztorch.nn.initr   r   r	   Ztorch.nn.parameterr
   Úmoduler   r!   r   r   r   r/   r7   r=   rF   rH   rK   rN   rP   rQ   rR   rS   rZ   r[   r\   re   rf   rl   ro   rp   rs   rt   r›   rŸ   r    r¡   r¬   r®   r±   r   r   r   r   Ú<module>   sL   2*?H#'"(*,1!(2,( %B/9