you can use the functional interface, where:
import torch.nn.functional as F
# in __init__
weight = nn.Parameter(torch.randn(20, 30))
bias = nn.Parameter(torch.randn(30))


# and later in forward(input1, input2):
out1 = F.linear(input1, weight, bias)
out2 = F.linear(input2, weight, bias)