U
    ‰d  ã                   @   s8   d dl mZ ddlmZ ddlmZ G dd„ deƒZdS )	é   )ÚModuleé   )Ú
functionalé    )ÚTensorc                       sV   e Zd ZU dZdgZeed< eddœ‡ fdd„Zeedœdd	„Z	e
d
œdd„Z‡  ZS )ÚChannelShufflea/  Divide the channels in a tensor of shape :math:`(*, C , H, W)`
    into g groups and rearrange them as :math:`(*, C \frac g, g, H, W)`,
    while keeping the original tensor shape.

    Args:
        groups (int): number of groups to divide channels in.

    Examples::

        >>> channel_shuffle = nn.ChannelShuffle(2)
        >>> input = torch.randn(1, 4, 2, 2)
        >>> print(input)
        [[[[1, 2],
           [3, 4]],
          [[5, 6],
           [7, 8]],
          [[9, 10],
           [11, 12]],
          [[13, 14],
           [15, 16]],
         ]]
        >>> output = channel_shuffle(input)
        >>> print(output)
        [[[[1, 2],
           [3, 4]],
          [[9, 10],
           [11, 12]],
          [[5, 6],
           [7, 8]],
          [[13, 14],
           [15, 16]],
         ]]
    ÚgroupsN)r   Úreturnc                    s   t t| ƒ ¡  || _d S ©N)Úsuperr   Ú__init__r   )Úselfr   ©Ú	__class__© úC/tmp/pip-unpacked-wheel-ua33x9lu/torch/nn/modules/channelshuffle.pyr   ,   s    zChannelShuffle.__init__)Úinputr	   c                 C   s   t  || j¡S r
   )ÚFZchannel_shuffler   )r   r   r   r   r   Úforward0   s    zChannelShuffle.forward)r	   c                 C   s   d  | j¡S )Nz	groups={})Úformatr   )r   r   r   r   Ú
extra_repr3   s    zChannelShuffle.extra_repr)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Z__constants__ÚintÚ__annotations__r   r   r   Ústrr   Ú__classcell__r   r   r   r   r      s   
!r   N)Úmoduler   Ú r   r   Ztorchr   r   r   r   r   r   Ú<module>   s   