```python
import torch
import torch.nn as nn
from torch.utils.cpp_extension import load_inline


_cpp_source = r"""
#include <torch/extension.h>

torch::Tensor fused_pool_sum_cuda(torch::Tensor x);
"""

_cuda_source = r"""
#include <torch/extension.h>
#include <ATen/AccumulateType.h>
#include <ATen/cuda/CUDAContext.h>
#include <c10/cuda/CUDAGuard.h>
#include <c10/cuda/CUDAException.h>
#include <cuda.h>
#include <cuda_runtime.h>

template <typename T>
__device__ __forceinline__ T nan_max(T a, T b) {
    return (isnan(b) || b > a) ? b : a;
}

// Non-overlapping max pools of sizes 2 and 3 compose into a
// non-overlapping max pool of size 6.
template <typename scalar_t, typename acc_t>
__global__ void fused_pool_sum_kernel(
    const scalar_t* __restrict__ x,
    scalar_t* __restrict__ output,
    int64_t channels,
    int64_t depth,
    int64_t height,
    int64_t width,
    int64_t output_depth,
    int64_t output_height,
    int64_t output_width
) {
    constexpr int WARPS = 8;
    constexpr unsigned MASK = 0xffffffffu;

    const int lane = threadIdx.x & 31;
    const int warp = threadIdx.x >> 5;
    const int64_t output_index = blockIdx.x;
    const int64_t output_volume =
        output_depth * output_height * output_width;

    const int64_t batch = output_index / output_volume;
    const int64_t position = output_index % output_volume;
    const int64_t ow = position % output_width;
    const int64_t oh = (position / output_width) % output_height;
    const int64_t od = position / (output_height * output_width);

    const int64_t input_volume = depth * height * width;
    const int64_t spatial_base =
        (od * 6 * height + oh * 6) * width + ow * 6;

    acc_t channel_sum = acc_t(0);

    for (int64_t channel = warp; channel < channels; channel += WARPS) {
        const scalar_t* base =
            x + (batch * channels + channel) * input_volume + spatial_base;

        acc_t maximum = -static_cast<acc_t>(INFINITY);

        #pragma unroll
        for (int i = 0; i < 7; ++i) {
            const int q = lane + i * 32;
            if (q < 216) {
                const int dz = q / 36;
                const int dy = (q / 6) % 6;
                const int dx = q % 6;
                const acc_t value =
                    static_cast<acc_t>(base[(dz * height + dy) * width + dx]);
                maximum = nan_max(maximum, value);
            }
        }

        #pragma unroll
        for (int offset = 16; offset > 0; offset >>= 1) {
            maximum = nan_max(
                maximum, __shfl_down_sync(MASK, maximum, offset)
            );
        }

        if (lane == 0) {
            channel_sum += maximum;
        }
    }

    __shared__ acc_t partial_sums[WARPS];
    if (lane == 0) {
        partial_sums[warp] = channel_sum;
    }
    __syncthreads();

    if (warp == 0) {
        acc_t total = lane < WARPS ? partial_sums[lane] : acc_t(0);

        #pragma unroll
        for (int offset = 16; offset > 0; offset >>= 1) {
            total += __shfl_down_sync(MASK, total, offset);
        }

        if (lane == 0) {
            output[output_index] = static_cast<scalar_t>(total);
        }
    }
}

torch::Tensor fused_pool_sum_cuda(torch::Tensor x) {
    TORCH_CHECK(x.is_cuda(), "Expected a CUDA tensor");
    TORCH_CHECK(x.dim() == 5, "Expected an NCDHW tensor");
    TORCH_CHECK(
        x.size(2) >= 6 && x.size(3) >= 6 && x.size(4) >= 6,
        "Spatial dimensions must be at least 6"
    );

    const c10::cuda::CUDAGuard device_guard(x.device());
    x = x.contiguous();

    const int64_t n = x.size(0);
    const int64_t c = x.size(1);
    const int64_t d = x.size(2);
    const int64_t h = x.size(3);
    const int64_t w = x.size(4);
    const int64_t od = d / 6;
    const int64_t oh = h / 6;
    const int64_t ow = w / 6;

    auto output = torch::empty({n, 1, od, oh, ow}, x.options());
    const int64_t blocks = n * od * oh * ow;

    if (blocks == 0) {
        return output;
    }

    TORCH_CHECK(blocks <= 2147483647LL, "Output is too large");
    const auto stream = at::cuda::getCurrentCUDAStream();

    AT_DISPATCH_FLOATING_TYPES_AND2(
        at::ScalarType::Half,
        at::ScalarType::BFloat16,
        x.scalar_type(),
        "fused_pool_sum_cuda",
        [&] {
            using acc_t = at::acc_type<scalar_t, true>;
            fused_pool_sum_kernel<scalar_t, acc_t>
                <<<static_cast<unsigned int>(blocks), 256, 0, stream>>>(
                    x.data_ptr<scalar_t>(),
                    output.data_ptr<scalar_t>(),
                    c, d, h, w, od, oh, ow
                );
        }
    );

    C10_CUDA_KERNEL_LAUNCH_CHECK();
    return output;
}
"""

_fused_ops = load_inline(
    name="fused_maxpool3d_sum_v1",
    cpp_sources=_cpp_source,
    cuda_sources=_cuda_source,
    functions=["fused_pool_sum_cuda"],
    extra_cflags=["-O3"],
    extra_cuda_cflags=["-O3"],
    verbose=False,
)


class ModelNew(nn.Module):
    def __init__(self, in_channels, out_channels, kernel_size, stride, padding):
        super().__init__()
        self.conv_transpose = nn.ConvTranspose3d(
            in_channels,
            out_channels,
            kernel_size,
            stride=stride,
            padding=padding,
        )
        self.max_pool1 = nn.MaxPool3d(kernel_size=2)
        self.max_pool2 = nn.MaxPool3d(kernel_size=3)

    def forward(self, x):
        x = self.conv_transpose(x)

        if not x.is_cuda or (torch.is_grad_enabled() and x.requires_grad):
            return self.max_pool2(self.max_pool1(x)).sum(dim=1, keepdim=True)

        return _fused_ops.fused_pool_sum_cuda(x)
```