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


_cpp_source = r"""
torch::Tensor pool6_bias_sum_cuda(torch::Tensor x, torch::Tensor bias);
"""

_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_runtime.h>
#include <cmath>
#include <cstdint>

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

template <typename scalar_t>
__global__ void pool6_bias_sum_kernel(
    const scalar_t* __restrict__ x,
    const scalar_t* __restrict__ bias,
    scalar_t* __restrict__ out,
    int channels,
    int od, int oh, int ow,
    int64_t sn, int64_t sc,
    int64_t sd, int64_t sh, int64_t sw
) {
    using acc_t = at::acc_type<scalar_t, true>;
    __shared__ acc_t maxima[4][64];
    __shared__ acc_t sums[2];

    const int tid = threadIdx.x;
    const int channel_lane = tid & 63;
    const int group = tid >> 6;
    const int index = blockIdx.x;
    const int spatial_size = od * oh * ow;

    const int n = index / spatial_size;
    int spatial = index % spatial_size;
    const int w = spatial % ow;
    spatial /= ow;
    const int h = spatial % oh;
    const int d = spatial / oh;

    const int64_t origin =
        int64_t(n) * sn + int64_t(d * 6) * sd +
        int64_t(h * 6) * sh + int64_t(w * 6) * sw;

    acc_t channel_sum = acc_t(0);

    for (int first_channel = 0; first_channel < channels;
         first_channel += 64) {
        const int channel = first_channel + channel_lane;
        acc_t value = -static_cast<acc_t>(INFINITY);

        if (channel < channels) {
            const scalar_t* base = x + origin + int64_t(channel) * sc;

            #pragma unroll
            for (int p = group; p < 216; p += 4) {
                const int dz = p / 36;
                const int dy = (p % 36) / 6;
                const int dx = p % 6;
                value = maximum_nan(
                    value,
                    static_cast<acc_t>(
                        base[int64_t(dz) * sd +
                             int64_t(dy) * sh + int64_t(dx) * sw]
                    )
                );
            }
        }

        maxima[group][channel_lane] = value;
        __syncthreads();

        if (group == 0 && channel < channels) {
            acc_t pooled = maximum_nan(
                maximum_nan(maxima[0][channel_lane],
                            maxima[1][channel_lane]),
                maximum_nan(maxima[2][channel_lane],
                            maxima[3][channel_lane])
            );

            // Match the convolution output's dtype before channel reduction.
            scalar_t biased = static_cast<scalar_t>(
                pooled + static_cast<acc_t>(bias[channel])
            );
            channel_sum += static_cast<acc_t>(biased);
        }
        __syncthreads();
    }

    if (tid < 64) {
        #pragma unroll
        for (int offset = 16; offset > 0; offset >>= 1) {
            channel_sum += __shfl_down_sync(
                0xffffffff, channel_sum, offset
            );
        }
        if ((tid & 31) == 0) {
            sums[tid >> 5] = channel_sum;
        }
    }
    __syncthreads();

    if (tid == 0) {
        out[index] = static_cast<scalar_t>(sums[0] + sums[1]);
    }
}

torch::Tensor pool6_bias_sum_cuda(torch::Tensor x, torch::Tensor bias) {
    TORCH_CHECK(x.is_cuda() && bias.is_cuda(), "Expected CUDA tensors");
    TORCH_CHECK(x.dim() == 5, "Expected a five-dimensional tensor");
    TORCH_CHECK(x.device() == bias.device(), "Device mismatch");

    const c10::cuda::CUDAGuard guard(x.device());
    const int64_t n = x.size(0);
    const int c = static_cast<int>(x.size(1));
    const int od = static_cast<int>(x.size(2) / 6);
    const int oh = static_cast<int>(x.size(3) / 6);
    const int ow = static_cast<int>(x.size(4) / 6);

    TORCH_CHECK(c > 0 && od > 0 && oh > 0 && ow > 0,
                "Input is too small for pooling");
    TORCH_CHECK(bias.numel() == c, "Invalid bias size");

    bias = bias.to(x.scalar_type()).contiguous();
    auto output = torch::empty({n, 1, od, oh, ow}, x.options());
    if (output.numel() == 0) {
        return output;
    }

    const auto stream = at::cuda::getCurrentCUDAStream();

    AT_DISPATCH_FLOATING_TYPES_AND2(
        at::ScalarType::Half,
        at::ScalarType::BFloat16,
        x.scalar_type(),
        "pool6_bias_sum_cuda",
        [&] {
            pool6_bias_sum_kernel<scalar_t>
                <<<static_cast<unsigned int>(output.numel()), 256, 0, stream>>>(
                    x.data_ptr<scalar_t>(),
                    bias.data_ptr<scalar_t>(),
                    output.data_ptr<scalar_t>(),
                    c, od, oh, ow,
                    x.stride(0), x.stride(1), x.stride(2),
                    x.stride(3), x.stride(4)
                );
        }
    );
    C10_CUDA_KERNEL_LAUNCH_CHECK();
    return output;
}
"""

_fused_ops = load_inline(
    name="pool6_bias_sum_channels_last_v2",
    cpp_sources=_cpp_source,
    cuda_sources=_cuda_source,
    functions=["pool6_bias_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,
        ).to(memory_format=torch.channels_last_3d)

        self.max_pool1 = nn.MaxPool3d(kernel_size=2)
        self.max_pool2 = nn.MaxPool3d(kernel_size=3)

    def forward(self, x):
        if not x.is_cuda:
            x = self.conv_transpose(x)
            return self.max_pool2(self.max_pool1(x)).sum(dim=1, keepdim=True)

        conv = self.conv_transpose
        x = x.contiguous(memory_format=torch.channels_last_3d)
        weight = conv.weight.contiguous(memory_format=torch.channels_last_3d)

        x = F.conv_transpose3d(
            x,
            weight,
            bias=None,
            stride=conv.stride,
            padding=conv.padding,
            output_padding=conv.output_padding,
            groups=conv.groups,
            dilation=conv.dilation,
        )
        return _fused_ops.pool6_bias_sum_cuda(x, conv.bias)
```