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


class Model(nn.Module):
    def __init__(self, target):
        super(Model, self).__init__()
        self.target = nn.Parameter(target)

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        dot = torch.sum(x * self.target, dim=-1)
        norm_x = torch.sqrt(torch.sum(x * x, dim=-1))
        norm_target = torch.sqrt(torch.sum(self.target * self.target, dim=-1))

        cosine = dot / (norm_x * norm_target + 1e-6)

        swish = cosine * torch.sigmoid(cosine)
        return F.gelu(swish)


batch_size = 128
input_dim = 1024


def get_inputs():
    x = torch.randn(batch_size, input_dim)
    return [x]


def get_init_inputs():
    target = torch.randn(input_dim)
    return [target]