Write a custom CUDA kernel to optimize `TanhSoft-2`.

Formula: f(x) = x * tanh(beta * exp(gamma * x))

Problem Analysis:
1. Computationally Intensive & Memory Bound: The operation is element-wise but involves a chain of expensive transcendental functions (exp, tanh).
2. Operator Chaining: A standard PyTorch implementation creates intermediate tensors.

Optimization Strategy: Fused Element-wise Kernel with Vectorization

1. One-Thread-per-Element: Map each element to a CUDA thread.

2. Vectorized Loads (float4): Use `float4` to process 128 bits per memory transaction.

3. Fused Stable Math:
   - For each element `x`:
     `gx = gamma * x`
     `clamped_gx = fminf(gx, 80.0f)` (Clamp for stability)
     `exp_val = __expf(clamped_gx)`
     `tanh_val = tanhf(beta * exp_val)`
     `result = x * tanh_val`
   - All steps are fused in registers.

4. One-Pass: Fuse all steps into a single read-compute-write kernel.
  
Here's an example to show you the syntax of inline embedding custom CUDA operators in torch: The example given architecture is:   
  
```python
import torch
import torch.nn as nn

BATCH_SIZE = 4096
HIDDEN_DIM = 4096
SHAPE = (BATCH_SIZE, HIDDEN_DIM)

BETA_INIT = 1.0
GAMMA_INIT = 1.0

class TanhSoft2(nn.Module):
    '''
    TanhSoft—Dynamic Trainable Activation Functions for Faster Learning and Better Performance
    https://ieeexplore.ieee.org/document/9514829
    Formula: f(x) = x * tanh(beta * exp(gamma * x))
    '''
    def __init__(self, beta_init=1.0, gamma_init=1.0):
        super(TanhSoft2, self).__init__()
        self.beta = nn.Parameter(torch.tensor(beta_init))
        self.gamma = nn.Parameter(torch.tensor(gamma_init))
        self.clamp_val = 80.0

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        clamped_gx = torch.clamp(self.gamma * x, max=self.clamp_val)
        inner = self.beta * torch.exp(clamped_gx)
        return x * torch.tanh(inner)

class Model(nn.Module):
    def __init__(self, beta_init=1.0, gamma_init=1.0):
        super(Model, self).__init__()
        self.act = TanhSoft2(beta_init, gamma_init)
    
    def forward(self, x):
        return self.act(x)

def get_inputs():
    input_tensor = torch.randn(SHAPE, dtype=torch.float32) * 5.0
    return [input_tensor.contiguous()]

def get_init_inputs():
    return [BETA_INIT, GAMMA_INIT]