import torch
import torch.nn as nn


class Model(nn.Module):
    def __init__(self):
        super().__init__()

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        x_abs = x.abs()

        y_mid = torch.where(
            x >= 0,
            x - x.pow(2) / 4.0,
            x + x.pow(2) / 4.0
        )

        y_saturated = torch.where(
            x > 2.0,
            torch.tensor(1.0, dtype=x.dtype, device=x.device),
            torch.where(
                x < -2.0,
                torch.tensor(-1.0, dtype=x.dtype, device=x.device),
                y_mid
            )
        )
        return y_saturated


batch_size = 128
feature_dim = 512


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


def get_init_inputs():
    return []