```python
import torch
import torch.nn as nn
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.h>
#include <cuda_runtime.h>

constexpr int STATS_THREADS = 256;
constexpr int CHUNK_SIZE = 4096;

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

__global__ void partial_moments(
    const float* __restrict__ x,
    float2* __restrict__ partial,
    int group_size,
    int chunks
) {
    const int chunk = blockIdx.x;
    const int row = blockIdx.y;
    const int tid = threadIdx.x;
    const int start = chunk * CHUNK_SIZE;
    const float* base = x + static_cast<int64_t>(row) * group_size;

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

    #pragma unroll
    for (int j = 0; j < CHUNK_SIZE / STATS_THREADS; ++j) {
        const int index = start + tid + j * STATS_THREADS;
        if (index < group_size) {
            const float value = base[index];
            sum += value;
            square_sum = fmaf(value, value, square_sum);
        }
    }

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

    __shared__ float shared_sum[8];
    __shared__ float shared_square_sum[8];

    const int lane = tid & 31;
    const int warp = tid >> 5;
    if (lane == 0) {
        shared_sum[warp] = sum;
        shared_square_sum[warp] = square_sum;
    }
    __syncthreads();

    if (warp == 0) {
        sum = lane < 8 ? shared_sum[lane] : 0.0f;
        square_sum = lane < 8 ? shared_square_sum[lane] : 0.0f;
        sum = warp_sum(sum);
        square_sum = warp_sum(square_sum);

        if (lane == 0)
            partial[static_cast<int64_t>(row) * chunks + chunk] =
                make_float2(sum, square_sum);
    }
}

__global__ void finish_moments(
    const float2* __restrict__ partial,
    float2* __restrict__ moments,
    int group_size,
    int chunks,
    float eps
) {
    const int row = blockIdx.x;
    const int lane = threadIdx.x;
    float sum = 0.0f;
    float square_sum = 0.0f;

    for (int i = lane; i < chunks; i += 32) {
        const float2 value =
            partial[static_cast<int64_t>(row) * chunks + i];
        sum += value.x;
        square_sum += value.y;
    }

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

    if (lane == 0) {
        const float mean = sum / static_cast<float>(group_size);
        const float variance = fmaxf(
            fmaf(-mean, mean, square_sum / static_cast<float>(group_size)),
            0.0f
        );
        moments[row] = make_float2(mean, rsqrtf(variance + eps));
    }
}

template<int CHANNELS>
__global__ void fused_normalize_activate_logsumexp(
    const float* __restrict__ x,
    const float* __restrict__ weight,
    const float* __restrict__ bias,
    const float2* __restrict__ moments,
    float* __restrict__ output,
    int spatial,
    int groups
) {
    const int position = blockIdx.x * blockDim.x + threadIdx.x;
    const int batch = blockIdx.y;
    if (position >= spatial)
        return;

    const int channels_per_group = CHANNELS / groups;
    const float* input =
        x + static_cast<int64_t>(batch) * CHANNELS * spatial + position;

    float values[CHANNELS];
    float maximum = -CUDART_INF_F;

    #pragma unroll
    for (int channel = 0; channel < CHANNELS; ++channel) {
        const float original =
            input[static_cast<int64_t>(channel) * spatial];
        const float2 stats =
            moments[batch * groups + channel / channels_per_group];

        const float normalized = fmaf(
            (original - stats.x) * stats.y,
            weight[channel],
            bias[channel]
        );
        const float activated = tanhf(normalized);

        // tanh lies in [-1, 1], so Hardswish's clamp is unnecessary.
        const float hard_swish =
            (activated * (activated + 3.0f)) * (1.0f / 6.0f);
        const float residual = original + hard_swish;

        values[channel] = residual;
        maximum = fmaxf(maximum, residual);
    }

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

    output[static_cast<int64_t>(batch) * spatial + position] =
        maximum + __logf(exponential_sum);
}

torch::Tensor fused_post_conv_cuda(
    torch::Tensor x,
    torch::Tensor weight,
    torch::Tensor bias,
    int64_t groups,
    double eps
) {
    TORCH_CHECK(x.is_cuda(), "Expected a CUDA tensor");
    TORCH_CHECK(x.scalar_type() == torch::kFloat32, "Expected float32");
    TORCH_CHECK(x.dim() == 4 && x.size(1) == 64,
                "Expected an NCHW tensor with 64 channels");
    TORCH_CHECK(x.is_contiguous(), "Expected contiguous NCHW storage");
    TORCH_CHECK(groups > 0 && 64 % groups == 0, "Invalid group count");
    TORCH_CHECK(
        weight.is_cuda() && bias.is_cuda() &&
        weight.device() == x.device() && bias.device() == x.device() &&
        weight.scalar_type() == torch::kFloat32 &&
        bias.scalar_type() == torch::kFloat32 &&
        weight.is_contiguous() && bias.is_contiguous() &&
        weight.numel() == 64 && bias.numel() == 64,
        "Expected contiguous float32 affine parameters on the input device"
    );

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

    const int batch = static_cast<int>(x.size(0));
    const int spatial = static_cast<int>(x.size(2) * x.size(3));
    const int group_count = static_cast<int>(groups);
    const int group_size = (64 / group_count) * spatial;
    const int chunks = (group_size + CHUNK_SIZE - 1) / CHUNK_SIZE;

    auto output = torch::empty(
        {x.size(0), 1, x.size(2), x.size(3)}, x.options()
    );
    if (batch == 0 || spatial == 0)
        return output;

    auto partial = torch::empty(
        {static_cast<int64_t>(batch) * group_count, chunks, 2},
        x.options()
    );
    auto moments = torch::empty(
        {static_cast<int64_t>(batch) * group_count, 2},
        x.options()
    );

    partial_moments<<<
        dim3(chunks, batch * group_count), STATS_THREADS, 0, stream
    >>>(
        x.data_ptr<float>(),
        reinterpret_cast<float2*>(partial.data_ptr<float>()),
        group_size,
        chunks
    );
    C10_CUDA_KERNEL_LAUNCH_CHECK();

    finish_moments<<<batch * group_count, 32, 0, stream>>>(
        reinterpret_cast<const float2*>(partial.data_ptr<float>()),
        reinterpret_cast<float2*>(moments.data_ptr<float>()),
        group_size,
        chunks,
        static_cast<float>(eps)
    );
    C10_CUDA_KERNEL_LAUNCH_CHECK();

    constexpr int threads = 128;
    fused_normalize_activate_logsumexp<64><<<
        dim3((spatial + threads - 1) / threads, batch),
        threads, 0, stream
    >>>(
        x.data_ptr<float>(),
        weight.data_ptr<float>(),
        bias.data_ptr<float>(),
        reinterpret_cast<const float2*>(moments.data_ptr<float>()),
        output.data_ptr<float>(),
        spatial,
        group_count
    );
    C10_CUDA_KERNEL_LAUNCH_CHECK();

    return output;
}
"""

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

torch::Tensor fused_post_conv_cuda(
    torch::Tensor x,
    torch::Tensor weight,
    torch::Tensor bias,
    int64_t groups,
    double eps
);
"""

_fused_ops = load_inline(
    name="fused_gn_tanh_hswish_residual_lse_v1",
    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):
        x_conv = self.conv(x)

        if (
            x_conv.is_cuda
            and x_conv.dtype == torch.float32
            and x_conv.shape[1] == 64
            and x_conv.is_contiguous()
            and self.group_norm.weight.dtype == torch.float32
            and self.group_norm.bias.dtype == torch.float32
        ):
            return _fused_ops.fused_post_conv_cuda(
                x_conv,
                self.group_norm.weight,
                self.group_norm.bias,
                self.group_norm.num_groups,
                self.group_norm.eps,
            )

        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)
```