def pixel_unshuffle(x: Tensor, scale):
    """Pixel unshuffle.

    Args:
        x (Tensor): Input feature with shape (b, hh, hw, c).
        scale (int): Downsample ratio.

    Returns:
        Tensor: the pixel unshuffled feature.
    """
    b, hh, hw, c = size(x)
    out_channel = c * (scale**2)
    assert hh % scale == 0 and hw % scale == 0
    h = hh // scale
    w = hw // scale
    x_view = ops.reshape()(x, [b, h, scale, w, scale, c])
    return ops.reshape()(
        ops.permute()(x_view, [0, 1, 3, 5, 2, 4]), [b, h, w, out_channel]
    )
Pixel unshuffle.

Args:
x (Tensor): Input feature with shape (b, hh, hw, c).
scale (int): Downsample ratio.

Returns:
Tensor: the pixel unshuffled feature.
examples/08_esrgan/modeling/rrdbnet.py