import torch
import torch.nn as nn

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

DTYPE = torch.float64

class GCU(nn.Module):
    """
    GCU Activation Function.
    https://arxiv.org/pdf/2108.12943
    Formula: f(x) = x * cos(x)
    """
    def __init__(self):
        super(GCU, self).__init__()

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        return x * torch.cos(x)

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

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

def get_init_inputs():
    return []