import torch
import torch.nn as nn

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

DTYPE = torch.float64

class Gish(nn.Module):
    def __init__(self):
        super(Gish, self).__init__()
        # Clamp value for double precision exp
        self.exp_clamp = 700.0

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        clamped_x = torch.clamp(x, max=self.exp_clamp)
        inner_exp = torch.exp(clamped_x)
        outer_exp = torch.exp(-inner_exp)
        log_val = torch.log(2.0 - outer_exp)
        return x * log_val

class Model(nn.Module):
    def __init__(self):
        super(Model, self).__init__()
        self.act = Gish()
    
    def forward(self, x):
        return self.act(x)

def get_inputs():
    input_tensor = torch.randn(SHAPE, dtype=DTYPE) * 5.0
    return [input_tensor.contiguous()]

def get_init_inputs():
    return []