Thanks for your reply. I am sure that I don’t have a cached version  with an older version of your code where the c++ module only took 2 argument.  And the densefunction.apply() works alone. The process is as  follows:
    x = torch.randn((4,5))
    y_label = torch.randn((4,3))

    weight = torch.randn((3,5),requires_grad=True)
    bias = torch.randn(3,requires_grad=True)
    output = densefunction.apply(x, weight, bias)

    loss = (output - y_label).pow(2).sum()
    loss.backward()
    print(weight.grad)
    print(bias.grad)

The result is as follows:
#print(weight.grad)
tensor([[ 0.4120, -0.3259, -2.5679, -0.8549, -1.7054],
        [ 0.2807, -0.0275, -0.4202,  1.0669,  0.7516],
        [ 1.0337,  1.1368, -1.2103,  1.2529, -0.1512]])
#print(bias.grad)
tensor([1.7098, 0.9224, 1.0619])