Try this!
import torch
import math

class CustAct(torch.nn.Module):
    def __init__(self, degree=4, alphas=None):
        super(CustAct, self).__init__()
        if alphas:
            self.alphas = torch.nn.Parameter(torch.Tensor(alphas))
        else:
            self.alphas = torch.nn.Parameter(torch.ones(degree + 1))

        self.alphas.requiresGrad = True  # set requiresGrad to true!
        #self.beta.requiresGrad = True  # set requiresGrad to true!

    def forward(self, x):
        val = torch.zeros(x.size()).cuda()  # move to GPU
        for d in range(len(self.alphas)):
            val += self.alphas[d] * x

        return val

feature_dim = 128
linear = torch.nn.Sequential(
                torch.nn.Linear(feature_dim, feature_dim),
                CustAct(alphas=[1, 2, 3, 4]),
                torch.nn.Linear(feature_dim, feature_dim),
                torch.nn.ReLU6()

            )



linear.cuda() 

rand_inp = torch.randn((4, 128)).cuda()
out = linear(rand_inp)
print(out.shape)  # torch.Size([4, 128])