ó
    !Eñil  ã                   ób   • S SK Js  Jr  S SKJr  SSKJr  SS/r " S S\5      r	 " S S\5      r
g)	é    N)ÚTensoré   )ÚModuleÚPixelShuffleÚPixelUnshufflec                   ój   ^ • \ rS rSr% SrS/r\\S'   S\SS4U 4S jjrS\	S\	4S jr
S\4S	 jrS
rU =r$ )r   é
   aç  Rearrange elements in a tensor according to an upscaling factor.

Rearranges elements in a tensor of shape :math:`(*, C \times r^2, H, W)`
to a tensor of shape :math:`(*, C, H \times r, W \times r)`, where r is an upscale factor.

This is useful for implementing efficient sub-pixel convolution
with a stride of :math:`1/r`.

See the paper:
`Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network`_
by Shi et al. (2016) for more details.

Args:
    upscale_factor (int): factor to increase spatial resolution by

Shape:
    - Input: :math:`(*, C_{in}, H_{in}, W_{in})`, where * is zero or more batch dimensions
    - Output: :math:`(*, C_{out}, H_{out}, W_{out})`, where

.. math::
    C_{out} = C_{in} \div \text{upscale\_factor}^2

.. math::
    H_{out} = H_{in} \times \text{upscale\_factor}

.. math::
    W_{out} = W_{in} \times \text{upscale\_factor}

Examples::

    >>> pixel_shuffle = nn.PixelShuffle(3)
    >>> input = torch.randn(1, 9, 4, 4)
    >>> output = pixel_shuffle(input)
    >>> print(output.size())
    torch.Size([1, 1, 12, 12])

.. _Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network:
    https://arxiv.org/abs/1609.05158
Úupscale_factorÚreturnNc                 ó.   >• [         TU ]  5         Xl        g ©N)ÚsuperÚ__init__r
   )Úselfr
   Ú	__class__s     €ÚZ/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/nn/modules/pixelshuffle.pyr   ÚPixelShuffle.__init__6   s   ø€ Ü‰ÑÔØ,Õó    Úinputc                 óB   • [         R                  " XR                  5      $ ©z
Runs the forward pass.
)ÚFÚpixel_shuffler
   ©r   r   s     r   ÚforwardÚPixelShuffle.forward:   s   € ô �Š˜u×&9Ñ&9Ó:Ð:r   c                 ó    • SU R                    3$ )ú0
Return the extra representation of the module.
zupscale_factor=©r
   ©r   s    r   Ú
extra_reprÚPixelShuffle.extra_repr@   s   € ð ! ×!4Ñ!4Ð 5Ð6Ð6r   r   ©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__constants__ÚintÚ__annotations__r   r   r   Ústrr!   Ú__static_attributes__Ú__classcell__©r   s   @r   r   r   
   sP   ø‡ ñ&ðP &Ð&€MØÓð- sð -¨t÷ -ð;˜Vð ;¨ô ;ð7˜C÷ 7ò 7r   c                   ój   ^ • \ rS rSr% SrS/r\\S'   S\SS4U 4S jjrS\	S\	4S jr
S\4S	 jrS
rU =r$ )r   éG   a³  Reverse the PixelShuffle operation.

Reverses the :class:`~torch.nn.PixelShuffle` operation by rearranging elements
in a tensor of shape :math:`(*, C, H \times r, W \times r)` to a tensor of shape
:math:`(*, C \times r^2, H, W)`, where r is a downscale factor.

See the paper:
`Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network`_
by Shi et al. (2016) for more details.

Args:
    downscale_factor (int): factor to decrease spatial resolution by

Shape:
    - Input: :math:`(*, C_{in}, H_{in}, W_{in})`, where * is zero or more batch dimensions
    - Output: :math:`(*, C_{out}, H_{out}, W_{out})`, where

.. math::
    C_{out} = C_{in} \times \text{downscale\_factor}^2

.. math::
    H_{out} = H_{in} \div \text{downscale\_factor}

.. math::
    W_{out} = W_{in} \div \text{downscale\_factor}

Examples::

    >>> pixel_unshuffle = nn.PixelUnshuffle(3)
    >>> input = torch.randn(1, 1, 12, 12)
    >>> output = pixel_unshuffle(input)
    >>> print(output.size())
    torch.Size([1, 9, 4, 4])

.. _Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network:
    https://arxiv.org/abs/1609.05158
Údownscale_factorr   Nc                 ó.   >• [         TU ]  5         Xl        g r   )r   r   r2   )r   r2   r   s     €r   r   ÚPixelUnshuffle.__init__q   s   ø€ Ü‰ÑÔØ 0Õr   r   c                 óB   • [         R                  " XR                  5      $ r   )r   Úpixel_unshuffler2   r   s     r   r   ÚPixelUnshuffle.forwardu   s   € ô × Ò  ×(=Ñ(=Ó>Ð>r   c                 ó    • SU R                    3$ )r   zdownscale_factor=©r2   r    s    r   r!   ÚPixelUnshuffle.extra_repr{   s   € ð # 4×#8Ñ#8Ð"9Ð:Ð:r   r9   r#   r/   s   @r   r   r   G   sP   ø‡ ñ$ðL (Ð(€MØÓð1¨ð 1°÷ 1ð?˜Vð ?¨ô ?ð;˜C÷ ;ò ;r   )Útorch.nn.functionalÚnnÚ
functionalr   Útorchr   Úmoduler   Ú__all__r   r   © r   r   Ú<module>rB      s7   ðß Ð Ý å ð Ð+Ð
,€ô:7�6ô :7ôz8;�Võ 8;r   