```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"""
#include <torch/extension.h>
#include <vector>

std::vector<torch::Tensor> prepare_transpose3d(
    torch::Tensor input, torch::Tensor weight);
torch::Tensor expand_transpose3d(torch::Tensor input);
"""

_cuda_source = r"""
#include <torch/extension.h>
#include <c10/cuda/CUDAGuard.h>
#include <c10/cuda/CUDAStream.h>
#include <c10/cuda/CUDAException.h>
#include <cuda_runtime.h>
#include <algorithm>
#include <cstdint>
#include <vector>

__global__ void prepare_kernel(
    const float* __restrict__ input,
    const float* __restrict__ weight,
    float* __restrict__ converted_input,
    float* __restrict__ converted_weight,
    int in_channels,
    int out_channels,
    int channel_tiles,
    int input_blocks,
    int64_t weight_count)
{
    if (blockIdx.x < input_blocks) {
        __shared__ float tile[32][33];

        const int lane = threadIdx.x & 31;
        const int row = threadIdx.x >> 5;
        const int spatial_tile = blockIdx.x % 512;
        const int channel_tile = (blockIdx.x / 512) % channel_tiles;
        const int batch = blockIdx.x / (512 * channel_tiles);
        const int spatial = spatial_tile * 32 + lane;

        #pragma unroll
        for (int j = 0; j < 32; j += 8) {
            const int channel = channel_tile * 32 + row + j;
            if (channel < in_channels) {
                tile[row + j][lane] =
                    input[(int64_t(batch) * in_channels + channel) *
                          16384 + spatial];
            }
        }

        __syncthreads();

        const int channel = channel_tile * 32 + lane;
        if (channel < in_channels) {
            #pragma unroll
            for (int j = 0; j < 32; j += 8) {
                const int destination_spatial =
                    spatial_tile * 32 + row + j;
                converted_input[
                    (int64_t(batch) * 16384 + destination_spatial) *
                    in_channels + channel] = tile[lane][row + j];
            }
        }
    } else {
        const int64_t i =
            int64_t(blockIdx.x - input_blocks) * 256 + threadIdx.x;

        if (i < weight_count) {
            const int ic = i % in_channels;
            const int k = (i / in_channels) % 27;
            const int oc = i / (int64_t(in_channels) * 27);

            converted_weight[i] =
                weight[(int64_t(ic) * out_channels + oc) * 27 + 26 - k];
        }
    }
}

__device__ __forceinline__ void streaming_store(
    float4* address, float4 value)
{
    asm volatile(
        "st.global.cs.v4.f32 [%0], {%1, %2, %3, %4};"
        :
        : "l"(address), "f"(value.x), "f"(value.y),
          "f"(value.z), "f"(value.w)
        : "memory");
}

template<int FixedChannelVectors>
__global__ void expand_kernel(
    const float4* __restrict__ input,
    float4* __restrict__ output,
    uint32_t main_vectors,
    uint32_t total_vectors,
    uint32_t runtime_channel_vectors)
{
    const uint32_t channel_vectors =
        FixedChannelVectors ? FixedChannelVectors : runtime_channel_vectors;
    const uint32_t step = gridDim.x * blockDim.x * 4;

    for (uint32_t base = blockIdx.x * blockDim.x * 4 + threadIdx.x;
         base < total_vectors;
         base += step) {
        #pragma unroll
        for (int j = 0; j < 4; ++j) {
            const uint32_t v = base + j * blockDim.x;
            if (v < total_vectors) {
                float4 value = make_float4(0.f, 0.f, 0.f, 0.f);

                if (v < main_vectors) {
                    const uint32_t spatial = v / channel_vectors;

                    // Odd width, height, and depth coordinates contain data.
                    if ((spatial & 4161u) == 4161u) {
                        const uint32_t compact_spatial =
                            ((spatial >> 1) & 31u) |
                            ((spatial >> 2) & 992u) |
                            ((spatial >> 3) & ~1023u);
                        const uint32_t channel = v % channel_vectors;
                        value = __ldg(
                            input + compact_spatial * channel_vectors + channel);
                    }
                }

                streaming_store(output + v, value);
            }
        }
    }
}

std::vector<torch::Tensor> prepare_transpose3d(
    torch::Tensor input, torch::Tensor weight)
{
    const c10::cuda::CUDAGuard guard(input.device());

    TORCH_CHECK(input.is_cuda() && weight.is_cuda());
    TORCH_CHECK(input.device() == weight.device());
    TORCH_CHECK(input.scalar_type() == at::kFloat);
    TORCH_CHECK(weight.scalar_type() == at::kFloat);
    TORCH_CHECK(input.is_contiguous() && weight.is_contiguous());
    TORCH_CHECK(
        input.dim() == 5 && input.size(2) == 16 &&
        input.size(3) == 32 && input.size(4) == 32);
    TORCH_CHECK(
        weight.dim() == 5 && weight.size(0) == input.size(1) &&
        weight.size(2) == 3 && weight.size(3) == 3 && weight.size(4) == 3);

    const int64_t batch = input.size(0);
    const int ic = input.size(1);
    const int oc = weight.size(1);

    auto input_storage = torch::empty(
        {batch, 16, 32, 32, ic}, input.options());
    auto weight_storage = torch::empty(
        {oc, 3, 3, 3, ic}, weight.options());

    const int channel_tiles = (ic + 31) / 32;
    const int64_t input_blocks64 = batch * 512 * channel_tiles;
    const int64_t weight_blocks = (weight.numel() + 255) / 256;
    TORCH_CHECK(input_blocks64 + weight_blocks < INT32_MAX);

    const int input_blocks = static_cast<int>(input_blocks64);
    const int blocks = static_cast<int>(input_blocks64 + weight_blocks);
    const auto stream = c10::cuda::getCurrentCUDAStream();

    prepare_kernel<<<blocks, 256, 0, stream.stream()>>>(
        input.data_ptr<float>(),
        weight.data_ptr<float>(),
        input_storage.data_ptr<float>(),
        weight_storage.data_ptr<float>(),
        ic, oc, channel_tiles, input_blocks, weight.numel());

    C10_CUDA_KERNEL_LAUNCH_CHECK();

    return {
        input_storage.permute({0, 4, 1, 2, 3}),
        weight_storage.permute({0, 4, 1, 2, 3})
    };
}

torch::Tensor expand_transpose3d(torch::Tensor input)
{
    const c10::cuda::CUDAGuard guard(input.device());

    TORCH_CHECK(input.is_cuda());
    TORCH_CHECK(input.scalar_type() == at::kFloat);
    TORCH_CHECK(input.is_contiguous(at::MemoryFormat::ChannelsLast3d));
    TORCH_CHECK(
        input.dim() == 5 && input.size(2) == 16 &&
        input.size(3) == 32 && input.size(4) == 32);

    const int64_t batch = input.size(0);
    const int64_t channels = input.size(1);
    TORCH_CHECK(channels % 4 == 0);

    constexpr int64_t spatial_stride = 32 * 64 * 64;
    const int64_t main_count = batch * channels * spatial_stride;
    const int64_t total_count = main_count + channels * (4096 + 64 + 1);

    TORCH_CHECK(total_count / 4 < UINT32_MAX - 4194304u);

    auto storage = torch::empty({total_count}, input.options());

    const uint32_t main_vectors = main_count / 4;
    const uint32_t total_vectors = total_count / 4;
    const uint32_t channel_vectors = channels / 4;
    const int blocks = static_cast<int>(
        std::min<uint32_t>((total_vectors + 1023) / 1024, 4096));

    const auto stream = c10::cuda::getCurrentCUDAStream();
    const float4* source =
        reinterpret_cast<const float4*>(input.data_ptr<float>());
    float4* destination =
        reinterpret_cast<float4*>(storage.data_ptr<float>());

    if (channel_vectors == 16) {
        expand_kernel<16><<<blocks, 256, 0, stream.stream()>>>(
            source, destination, main_vectors, total_vectors, channel_vectors);
    } else {
        expand_kernel<0><<<blocks, 256, 0, stream.stream()>>>(
            source, destination, main_vectors, total_vectors, channel_vectors);
    }

    C10_CUDA_KERNEL_LAUNCH_CHECK();

    // Boundary rows and planes overlap only locations containing zero.
    return storage.as_strided(
        {batch, channels, 33, 65, 65},
        {
            channels * spatial_stride,
            1,
            channels * 4096,
            channels * 64,
            channels
        });
}
"""

_ops = load_inline(
    name="sparse_transpose3d_channels_last_v5",
    cpp_sources=_cpp_source,
    cuda_sources=_cuda_source,
    functions=["prepare_transpose3d", "expand_transpose3d"],
    extra_cflags=["-O3"],
    extra_cuda_cflags=["-O3"],
    verbose=False,
)


class ModelNew(nn.Module):
    def __init__(
        self,
        in_channels: int,
        out_channels: int,
        kernel_size: int,
        stride: int = 1,
        padding: int = 0,
        dilation: int = 1,
        bias: bool = False,
    ):
        super().__init__()
        self.conv_transpose3d = nn.ConvTranspose3d(
            in_channels,
            out_channels,
            kernel_size=(kernel_size, kernel_size, kernel_size),
            stride=stride,
            padding=padding,
            dilation=dilation,
            bias=bias,
        )

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        conv = self.conv_transpose3d
        supported = (
            x.is_cuda
            and x.ndim == 5
            and x.dtype == torch.float32
            and conv.weight.dtype == torch.float32
            and x.device == conv.weight.device
            and x.shape[0] > 0
            and x.shape[1] == conv.in_channels
            and x.shape[2:] == (16, 32, 32)
            and conv.out_channels % 4 == 0
            and conv.kernel_size == (3, 3, 3)
            and conv.stride == (2, 2, 2)
            and conv.padding == (1, 1, 1)
            and conv.dilation == (2, 2, 2)
            and conv.output_padding == (0, 0, 0)
            and conv.groups == 1
            and conv.bias is None
            and not torch.is_autocast_enabled()
            and x.shape[0] * conv.out_channels < 131000
        )
        if not supported:
            return conv(x)

        prepared_input, prepared_weight = _ops.prepare_transpose3d(
            x.contiguous(), conv.weight.contiguous()
        )
        compact = F.conv3d(
            prepared_input,
            prepared_weight,
            bias=None,
            stride=1,
            padding=1,
            dilation=1,
        )
        compact = compact.contiguous(memory_format=torch.channels_last_3d)
        return _ops.expand_transpose3d(compact)
```