How to extract smaller image patches (3D)?

Hi, you used the view method to fold the patches. However, it works when patches are non-overlapping. What should I do if the patches overlap and I want to sum the overlapped part in folding? I looked up the torch.nn.Fold which only supports the 2D batched image-like tensors with shape (N, C, H, W). But I want to fold 3D tensors with shape (N, C, Z, H, W). Are there any solutions to this problem? Thank you!