import torch
import torch.nn as nn

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

ALPHA_VAL = 0.75
BETA_VAL = 0.75

class ErfAct(nn.Module):
    """
    ErfAct Activation.
    https://link.springer.com/article/10.1007/s10044-024-01277-w
    Formula: f(x) = x * erf(alpha * exp(beta * x))
    """
    def __init__(self, alpha=0.75, beta=0.75):
        super(ErfAct, self).__init__()
        self.alpha = alpha
        self.beta = beta
        self.clamp_val = 80.0 # for float32

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        clamped_bx = torch.clamp(self.beta * x, max=self.clamp_val)
        inner_val = self.alpha * torch.exp(clamped_bx)
        erf_val = torch.erf(inner_val)
        return x * erf_val

class Model(nn.Module):
    def __init__(self, alpha=0.75, beta=0.75):
        super(Model, self).__init__()
        self.act = ErfAct(alpha, beta)
    
    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_VAL, BETA_VAL]