import torch
import torch.nn as nn
import torch.nn.functional as F

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

ALPHA_INIT = 1.0

class TanhSoft1(nn.Module):
    '''
    TanhSoft—Dynamic Trainable Activation Functions for Faster Learning and Better Performance
    https://ieeexplore.ieee.org/document/9514829
    Formula: f(x) = tanh(alpha * x) * softplus(x)
    '''
    def __init__(self, alpha_init=1.0):
        super(TanhSoft1, self).__init__()
        self.alpha = nn.Parameter(torch.tensor(alpha_init))

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        return torch.tanh(self.alpha * x) * F.softplus(x)

class Model(nn.Module):
    def __init__(self, alpha_init=1.0):
        super(Model, self).__init__()
        self.act = TanhSoft1(alpha_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 [ALPHA_INIT]