dilation=..., padding=..., stride=...) >>> fold = nn.Fold(output_size=..., **fold_params) >>> unfold = nn.Unfold(**fold_params) Then for any (supported) ``input`` tensor the following equality holds: :: fold(unfold(input)) == divisor * input where ``divisor`` is a tensor that depends only on the shape and dtype of the ``input``: >>> # xdoctest: +SKIP >>> input_ones = torch.ones(input.shape, dtype=input.dtype) >>> divisor = fold(unfold(input_ones)) When the ``divisor`` tensor contains no zero elements, then ``fold`` and ``unfold`` operations are inverses of each other (up to constant divisor). .. warning:: Currently, only unbatched (3D) or batched (4D) image-like output tensors are supported. Shape: - Input: :math:`(N, C \times \prod(\text{kernel\_size}), L)` or :math:`(C \times \prod(\text{kernel\_size}), L)` - Output: :math:`(N, C, \text{output\_size}[0], \text{output\_size}[1], \dots)` or :math:`(C, \text{output\_size}[0], \text{output\_size}[1], \dots)` as described above Examples:: >>> fold = nn.Fold(output_size=(4, 5), kernel_size=(2, 2)) >>> input = torch.randn(1, 3 * 2 * 2, 12) >>> output = fold(input) >>> output.size() torch.Size([1, 3, 4, 5]) .. _link: https://github.com/vdumoulin/conv_arithmetic/blob/master/README.md )