o
    h                     @   sD   d dl m  mZ d dlmZ ddlmZ dgZG dd deZ	dS )    N)Tensor   )ModuleChannelShufflec                       sZ   e Zd ZU dZdgZeed< deddf fddZdedefdd	Z	de
fd
dZ  ZS )r   a'  Divides and rearranges the channels in a tensor.

    This operation divides the channels in a tensor of shape :math:`(N, C, *)`
    into g groups as :math:`(N, \frac{C}{g}, g, *)` and shuffles them,
    while retaining the original tensor shape in the final output.

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

    Examples::

        >>> channel_shuffle = nn.ChannelShuffle(2)
        >>> input = torch.arange(1, 17, dtype=torch.float32).view(1, 4, 2, 2)
        >>> input
        tensor([[[[ 1.,  2.],
                  [ 3.,  4.]],
                 [[ 5.,  6.],
                  [ 7.,  8.]],
                 [[ 9., 10.],
                  [11., 12.]],
                 [[13., 14.],
                  [15., 16.]]]])
        >>> output = channel_shuffle(input)
        >>> output
        tensor([[[[ 1.,  2.],
                  [ 3.,  4.]],
                 [[ 9., 10.],
                  [11., 12.]],
                 [[ 5.,  6.],
                  [ 7.,  8.]],
                 [[13., 14.],
                  [15., 16.]]]])
    groupsreturnNc                    s   t    || _d S N)super__init__r   )selfr   	__class__ s/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/torch/nn/modules/channelshuffle.pyr
   0   s   

zChannelShuffle.__init__inputc                 C   s   t || jS r   )Fchannel_shuffler   )r   r   r   r   r   forward4   s   zChannelShuffle.forwardc                 C   s   d| j  S )Nzgroups=)r   )r   r   r   r   
extra_repr7   s   zChannelShuffle.extra_repr)__name__
__module____qualname____doc____constants__int__annotations__r
   r   r   strr   __classcell__r   r   r   r   r   
   s   
 ")
torch.nn.functionalnn
functionalr   torchr   moduler   __all__r   r   r   r   r   <module>   s
    