import torch
import torch.nn as nn
import math

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

K_VALUE = 0.5

class PATS(nn.Module):
    """
    PATS: a new neural network activation function with parameter (ICCCS 2020)
    https://ieeexplore.ieee.org/document/9118471
    Formula: f(x) = x * arctan(k * PI * sigmoid(x))
    """
    def __init__(self, k=0.5):
        super(PATS, self).__init__()
        self.k = k
        self.pi = math.pi

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        sig = torch.sigmoid(x)
        return x * torch.arctan(self.k * self.pi * sig)

class Model(nn.Module):
    def __init__(self, k=0.5):
        super(Model, self).__init__()
        self.act = PATS(k=k)
    
    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 [K_VALUE]