import torch
import torch.nn as nn

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

BETA_VALUE = 1.0

class NIPUNA(nn.Module):
    """
    NIPUNA Activation.
    https://www.mdpi.com/2075-1680/12/3/246
    f(x) = max(x / (1 + exp(-beta*x)), x)
    """
    def __init__(self, beta=1.0):
        super(NIPUNA, self).__init__()
        self.beta = beta

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        swish_part = x * torch.sigmoid(self.beta * x)
        return torch.max(swish_part, x)

class Model(nn.Module):
    def __init__(self, beta=1.0):
        super(Model, self).__init__()
        self.act = NIPUNA(beta=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 [BETA_VALUE]