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


_cpp_source = """
#include <torch/extension.h>
void subtract_tanh_cuda_(torch::Tensor x, torch::Tensor bias);
"""

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

__device__ __forceinline__ float activation(float x) {
    return tanhf(x);
}

__device__ __forceinline__ double activation(double x) {
    return tanh(x);
}

__global__ void subtract_tanh_float4(
    float* __restrict__ x,
    const float* __restrict__ bias,
    int64_t count,
    int64_t spatial,
    int64_t channels
) {
    const int64_t vectors = count / 4;
    const int64_t step = int64_t(blockDim.x) * gridDim.x;

    for (int64_t v = int64_t(blockIdx.x) * blockDim.x + threadIdx.x;
         v < vectors; v += step) {
        const int64_t i = v * 4;
        float4 value = reinterpret_cast<float4*>(x)[v];

        const int64_t c0 = (i / spatial) % channels;
        const int64_t c3 = ((i + 3) / spatial) % channels;
        if (c0 == c3) {
            const float b = bias[c0];
            value.x = tanhf(value.x - b);
            value.y = tanhf(value.y - b);
            value.z = tanhf(value.z - b);
            value.w = tanhf(value.w - b);
        } else {
            value.x = tanhf(value.x - bias[c0]);
            value.y = tanhf(value.y - bias[((i + 1) / spatial) % channels]);
            value.z = tanhf(value.z - bias[((i + 2) / spatial) % channels]);
            value.w = tanhf(value.w - bias[c3]);
        }
        reinterpret_cast<float4*>(x)[v] = value;
    }

    const int64_t tail = vectors * 4
        + int64_t(blockIdx.x) * blockDim.x + threadIdx.x;
    if (tail < count) {
        x[tail] = tanhf(x[tail] - bias[(tail / spatial) % channels]);
    }
}

template <typename scalar_t>
__global__ void subtract_tanh_scalar(
    scalar_t* __restrict__ x,
    const scalar_t* __restrict__ bias,
    int64_t count,
    int64_t spatial,
    int64_t channels
) {
    using acc_t = at::opmath_type<scalar_t>;
    const int64_t step = int64_t(blockDim.x) * gridDim.x;

    for (int64_t i = int64_t(blockIdx.x) * blockDim.x + threadIdx.x;
         i < count; i += step) {
        const acc_t value =
            static_cast<acc_t>(x[i]) -
            static_cast<acc_t>(bias[(i / spatial) % channels]);
        x[i] = static_cast<scalar_t>(activation(value));
    }
}

void subtract_tanh_cuda_(torch::Tensor x, torch::Tensor bias) {
    TORCH_CHECK(x.is_cuda() && bias.is_cuda(), "Expected CUDA tensors");
    TORCH_CHECK(x.device() == bias.device(), "Devices must match");
    TORCH_CHECK(x.scalar_type() == bias.scalar_type(), "Dtypes must match");
    TORCH_CHECK(x.dim() == 4 && x.is_contiguous(),
                "Expected contiguous NCHW input");
    TORCH_CHECK(bias.is_contiguous() && bias.numel() == x.size(1),
                "Expected one contiguous bias value per channel");

    const c10::cuda::CUDAGuard guard(x.device());
    const int64_t count = x.numel();
    if (count == 0) return;

    const int64_t spatial = x.size(2) * x.size(3);
    const int64_t channels = x.size(1);
    constexpr int threads = 256;
    const auto stream = at::cuda::getCurrentCUDAStream();

    if (x.scalar_type() == at::kFloat &&
        reinterpret_cast<uintptr_t>(x.data_ptr<float>()) % 16 == 0) {
        const int64_t work = (count + 3) / 4;
        const int blocks = static_cast<int>(
            std::min<int64_t>((work + threads - 1) / threads, 4096));
        subtract_tanh_float4<<<blocks, threads, 0, stream>>>(
            x.data_ptr<float>(), bias.data_ptr<float>(),
            count, spatial, channels);
    } else {
        const int blocks = static_cast<int>(
            std::min<int64_t>((count + threads - 1) / threads, 4096));
        AT_DISPATCH_FLOATING_TYPES_AND2(
            at::ScalarType::Half, at::ScalarType::BFloat16,
            x.scalar_type(), "subtract_tanh_cuda", [&] {
                subtract_tanh_scalar<scalar_t>
                    <<<blocks, threads, 0, stream>>>(
                        x.data_ptr<scalar_t>(), bias.data_ptr<scalar_t>(),
                        count, spatial, channels);
            });
    }
    C10_CUDA_KERNEL_LAUNCH_CHECK();
}
"""

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


class _SubtractTanh(torch.autograd.Function):
    @staticmethod
    def forward(ctx, x, bias):
        ctx.bias_shape = bias.shape
        ctx.mark_dirty(x)
        _fused_ops.subtract_tanh_cuda_(x, bias.contiguous())
        ctx.save_for_backward(x)
        return x

    @staticmethod
    def backward(ctx, grad_output):
        (output,) = ctx.saved_tensors
        grad = grad_output * (1 - output.square())
        grad_x = grad if ctx.needs_input_grad[0] else None
        grad_bias = None
        if ctx.needs_input_grad[1]:
            grad_bias = -grad.sum(dim=(0, 2, 3)).reshape(ctx.bias_shape)
        return grad_x, grad_bias


class ModelNew(nn.Module):
    def __init__(
        self,
        in_channels,
        out_channels,
        kernel_size,
        bias_shape,
        stride=2,
        padding=1,
        output_padding=1,
    ):
        super().__init__()
        self.conv_transpose = nn.ConvTranspose2d(
            in_channels,
            out_channels,
            kernel_size,
            stride=stride,
            padding=padding,
            output_padding=output_padding,
        )
        self.bias = nn.Parameter(torch.randn(bias_shape))

    def forward(self, x):
        x = self.conv_transpose(x)
        channel_bias = tuple(self.bias.shape) in (
            (x.shape[1], 1, 1),
            (1, x.shape[1], 1, 1),
        )
        if (
            x.is_cuda
            and x.is_contiguous()
            and self.bias.device == x.device
            and self.bias.dtype == x.dtype
            and channel_bias
            and x.dtype in (
                torch.float16,
                torch.bfloat16,
                torch.float32,
                torch.float64,
            )
        ):
            return _SubtractTanh.apply(x, self.bias)
        return torch.tanh(x - self.bias)
```