import torch
import torch.nn as nn

class Model(nn.Module):
    def __init__(self, scale: torch.Tensor, bias: torch.Tensor, gamma: float, beta: float):
        super(Model, self).__init__()
        self.scale = nn.Parameter(scale)
        self.bias = nn.Parameter(bias)
        self.gamma = nn.Parameter(torch.tensor(float(gamma), dtype=torch.float32))
        self.beta = nn.Parameter(torch.tensor(float(beta), dtype=torch.float32))

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        z = x * self.scale.view(1,-1) + self.bias.view(1,-1)
        zmax = torch.amax(z, dim=1, keepdim=True)
        zmin = torch.amin(z, dim=1, keepdim=True)
        g = torch.sigmoid(self.gamma * (zmax - zmin) + self.beta)
        return z * g

B, D = 64, 8192

def get_inputs():
    x = torch.randn(B, D)
    return [x]

def get_init_inputs():
    scale = torch.randn(D)
    bias = torch.randn(D)
    gamma = 1.0
    beta = 0.0
    return [scale, bias, gamma, beta]
