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:
        x_sorted, _ = torch.sort(x, dim=-1)
        target_sorted, _ = torch.sort(self.target, dim=-1)

        diff = x_sorted - target_sorted
        energy = torch.mean(diff * diff, dim=-1)

        return F.gelu(energy)


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]