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

BATCH_SIZE = 4096
DIM = 4096
SHAPE = (BATCH_SIZE, DIM)

class Phish(nn.Module):
    """
    Phish Activation Function.
    https://vixra.org/pdf/2112.0097v3.pdf
    Formula: f(x) = x * tanh(x * GELU(x))
    """
    def __init__(self):
        super(Phish, self).__init__()

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

class Model(nn.Module):
    def __init__(self):
        super(Model, self).__init__()
        self.act = Phish()
    
    def forward(self, x: torch.Tensor) -> torch.Tensor:
        return self.act(x)

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

def get_init_inputs():
    return []