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


_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 <math_constants.h>

constexpr int CHANNELS = 64;
constexpr int GROUPS = 16;
constexpr int SPATIAL_CHUNK = 256;

__device__ __forceinline__ float warp_sum(float value) {
    #pragma unroll
    for (int delta = 16; delta > 0; delta >>= 1)
        value += __shfl_down_sync(0xffffffffu, value, delta);
    return value;
}

__device__ __forceinline__ float fast_tanh(float value) {
#if __CUDA_ARCH__ >= 750
    float result;
    asm("tanh.approx.f32 %0, %1;" : "=f"(result) : "f"(value));
    return result;
#else
    return tanhf(value);
#endif
}

__global__ void partial_moments_nhwc(
    const float* __restrict__ input,
    const float* __restrict__ conv_bias,
    float2* __restrict__ partial,
    int spatial,
    int chunks
) {
    const int tid = threadIdx.x;
    const int group = tid & 15;
    const int spatial_lane = tid >> 4;
    const int batch = blockIdx.y;
    const int start = blockIdx.x * SPATIAL_CHUNK;

    const float4 b =
        reinterpret_cast<const float4*>(conv_bias)[group];

    float sum = 0.0f;
    float square_sum = 0.0f;

    #pragma unroll
    for (int offset = 0; offset < SPATIAL_CHUNK; offset += 16) {
        const int position = start + spatial_lane + offset;
        if (position < spatial) {
            float4 v = reinterpret_cast<const float4*>(input)[
                (static_cast<int64_t>(batch) * spatial + position) * GROUPS
                + group
            ];
            v.x += b.x;
            v.y += b.y;
            v.z += b.z;
            v.w += b.w;

            sum += (v.x + v.y) + (v.z + v.w);
            square_sum = fmaf(v.x, v.x, square_sum);
            square_sum = fmaf(v.y, v.y, square_sum);
            square_sum = fmaf(v.z, v.z, square_sum);
            square_sum = fmaf(v.w, v.w, square_sum);
        }
    }

    sum += __shfl_xor_sync(0xffffffffu, sum, 16);
    square_sum += __shfl_xor_sync(0xffffffffu, square_sum, 16);

    __shared__ float shared_sum[8][16];
    __shared__ float shared_square[8][16];

    if ((tid & 31) < 16) {
        shared_sum[tid >> 5][group] = sum;
        shared_square[tid >> 5][group] = square_sum;
    }
    __syncthreads();

    if (tid < GROUPS) {
        float total = 0.0f;
        float total_square = 0.0f;
        #pragma unroll
        for (int warp = 0; warp < 8; ++warp) {
            total += shared_sum[warp][tid];
            total_square += shared_square[warp][tid];
        }

        partial[
            (static_cast<int64_t>(batch) * chunks + blockIdx.x) * GROUPS
            + tid
        ] = make_float2(total, total_square);
    }
}

__global__ void finish_moments_nhwc(
    const float2* __restrict__ partial,
    float2* __restrict__ moments,
    int spatial,
    int chunks,
    float eps
) {
    const int row = blockIdx.x;
    const int batch = row / GROUPS;
    const int group = row % GROUPS;
    const int lane = threadIdx.x;

    float sum = 0.0f;
    float square_sum = 0.0f;

    for (int chunk = lane; chunk < chunks; chunk += 32) {
        const float2 v = partial[
            (static_cast<int64_t>(batch) * chunks + chunk) * GROUPS + group
        ];
        sum += v.x;
        square_sum += v.y;
    }

    sum = warp_sum(sum);
    square_sum = warp_sum(square_sum);

    if (lane == 0) {
        const float inverse_count = 1.0f / (4.0f * spatial);
        const float mean = sum * inverse_count;
        const float variance = fmaxf(
            fmaf(-mean, mean, square_sum * inverse_count), 0.0f
        );
        moments[row] = make_float2(mean, rsqrtf(variance + eps));
    }
}

__device__ __forceinline__ float activate_residual(
    float input,
    float conv_bias,
    float weight,
    float bias,
    float2 stats
) {
    const float original = input + conv_bias;
    const float normalized = fmaf(
        (original - stats.x) * stats.y, weight, bias
    );
    const float activated = fast_tanh(normalized);
    const float hard_swish =
        (activated * (activated + 3.0f)) * (1.0f / 6.0f);
    return original + hard_swish;
}

__global__ void fused_output_nhwc(
    const float* __restrict__ input,
    const float* __restrict__ conv_bias,
    const float* __restrict__ weight,
    const float* __restrict__ bias,
    const float2* __restrict__ moments,
    float* __restrict__ output,
    int spatial
) {
    // Eight neighboring threads jointly reduce one pixel's 64 channels.
    const int pixel = blockIdx.x * 32 + (threadIdx.x >> 3);
    const int lane = threadIdx.x & 7;
    const int batch = blockIdx.y;

    if (pixel >= spatial)
        return;

    const unsigned mask = __activemask();
    const int first_group = lane * 2;
    const int64_t base =
        (static_cast<int64_t>(batch) * spatial + pixel) * GROUPS;

    float values[8];

    #pragma unroll
    for (int half = 0; half < 2; ++half) {
        const int group = first_group + half;
        const float4 x =
            reinterpret_cast<const float4*>(input)[base + group];
        const float4 cb =
            reinterpret_cast<const float4*>(conv_bias)[group];
        const float4 w =
            reinterpret_cast<const float4*>(weight)[group];
        const float4 b =
            reinterpret_cast<const float4*>(bias)[group];
        const float2 stats = moments[batch * GROUPS + group];

        values[half * 4 + 0] =
            activate_residual(x.x, cb.x, w.x, b.x, stats);
        values[half * 4 + 1] =
            activate_residual(x.y, cb.y, w.y, b.y, stats);
        values[half * 4 + 2] =
            activate_residual(x.z, cb.z, w.z, b.z, stats);
        values[half * 4 + 3] =
            activate_residual(x.w, cb.w, w.w, b.w, stats);
    }

    float maximum = -CUDART_INF_F;
    #pragma unroll
    for (int i = 0; i < 8; ++i)
        maximum = fmaxf(maximum, values[i]);

    #pragma unroll
    for (int delta = 4; delta > 0; delta >>= 1)
        maximum = fmaxf(
            maximum, __shfl_xor_sync(mask, maximum, delta, 8)
        );

    float exponential_sum = 0.0f;
    #pragma unroll
    for (int i = 0; i < 8; ++i)
        exponential_sum += __expf(values[i] - maximum);

    #pragma unroll
    for (int delta = 4; delta > 0; delta >>= 1)
        exponential_sum +=
            __shfl_xor_sync(mask, exponential_sum, delta, 8);

    if (lane == 0)
        output[static_cast<int64_t>(batch) * spatial + pixel] =
            maximum + __logf(exponential_sum);
}

torch::Tensor fused_post_conv_cuda(
    torch::Tensor input,
    torch::Tensor conv_bias,
    torch::Tensor weight,
    torch::Tensor bias,
    double eps
) {
    TORCH_CHECK(
        input.is_cuda() &&
        input.scalar_type() == torch::kFloat32 &&
        input.dim() == 4 &&
        input.size(1) == CHANNELS &&
        input.is_contiguous(at::MemoryFormat::ChannelsLast),
        "Expected channels-last CUDA float32 input with 64 channels"
    );

    for (const auto& parameter : {conv_bias, weight, bias}) {
        TORCH_CHECK(
            parameter.device() == input.device() &&
            parameter.scalar_type() == torch::kFloat32 &&
            parameter.is_contiguous() &&
            parameter.numel() == CHANNELS,
            "Expected 64 contiguous float32 parameters on the input device"
        );
    }

    const c10::cuda::CUDAGuard guard(input.device());
    const auto stream =
        c10::cuda::getCurrentCUDAStream(input.get_device()).stream();

    const int batch = static_cast<int>(input.size(0));
    const int spatial =
        static_cast<int>(input.size(2) * input.size(3));

    auto output = torch::empty(
        {input.size(0), 1, input.size(2), input.size(3)},
        input.options()
    );

    if (batch == 0 || spatial == 0)
        return output;

    const int chunks =
        (spatial + SPATIAL_CHUNK - 1) / SPATIAL_CHUNK;

    auto partial = torch::empty(
        {batch, chunks, GROUPS, 2}, input.options()
    );
    auto moments = torch::empty(
        {batch, GROUPS, 2}, input.options()
    );

    partial_moments_nhwc<<<dim3(chunks, batch), 256, 0, stream>>>(
        input.data_ptr<float>(),
        conv_bias.data_ptr<float>(),
        reinterpret_cast<float2*>(partial.data_ptr<float>()),
        spatial,
        chunks
    );
    C10_CUDA_KERNEL_LAUNCH_CHECK();

    finish_moments_nhwc<<<batch * GROUPS, 32, 0, stream>>>(
        reinterpret_cast<const float2*>(partial.data_ptr<float>()),
        reinterpret_cast<float2*>(moments.data_ptr<float>()),
        spatial,
        chunks,
        static_cast<float>(eps)
    );
    C10_CUDA_KERNEL_LAUNCH_CHECK();

    fused_output_nhwc<<<dim3((spatial + 31) / 32, batch), 256, 0, stream>>>(
        input.data_ptr<float>(),
        conv_bias.data_ptr<float>(),
        weight.data_ptr<float>(),
        bias.data_ptr<float>(),
        reinterpret_cast<const float2*>(moments.data_ptr<float>()),
        output.data_ptr<float>(),
        spatial
    );
    C10_CUDA_KERNEL_LAUNCH_CHECK();

    return output;
}
"""

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

torch::Tensor fused_post_conv_cuda(
    torch::Tensor input,
    torch::Tensor conv_bias,
    torch::Tensor weight,
    torch::Tensor bias,
    double eps
);
"""

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


class ModelNew(nn.Module):
    def __init__(
        self, in_channels, out_channels, kernel_size, groups, eps=1e-5
    ):
        super().__init__()
        self.conv = nn.Conv2d(in_channels, out_channels, kernel_size)
        self.group_norm = nn.GroupNorm(groups, out_channels, eps=eps)
        self.tanh = nn.Tanh()
        self.hard_swish = nn.Hardswish()

    def forward(self, x):
        if (
            x.is_cuda
            and x.dtype == torch.float32
            and self.conv.out_channels == 64
            and self.group_norm.num_groups == 16
            and self.conv.weight.dtype == torch.float32
            and self.conv.bias is not None
            and self.conv.bias.dtype == torch.float32
            and self.group_norm.weight.dtype == torch.float32
            and self.group_norm.bias.dtype == torch.float32
            and not torch.is_autocast_enabled()
        ):
            x = x.contiguous(memory_format=torch.channels_last)
            conv_weight = self.conv.weight.contiguous(
                memory_format=torch.channels_last
            )
            x_conv = F.conv2d(
                x,
                conv_weight,
                None,
                self.conv.stride,
                self.conv.padding,
                self.conv.dilation,
                self.conv.groups,
            )
            return _fused_ops.fused_post_conv_cuda(
                x_conv,
                self.conv.bias,
                self.group_norm.weight,
                self.group_norm.bias,
                self.group_norm.eps,
            )

        x_conv = self.conv(x)
        x_norm = self.group_norm(x_conv)
        x_activated = self.hard_swish(self.tanh(x_norm))
        return torch.logsumexp(
            x_conv + x_activated, dim=1, keepdim=True
        )
```