You could either pass the size for all arguments as:
x = torch.randn(10, 20)
nn.Linear(*x.size())

or index the desired shapes and add the other arguments manually:
x = torch.randn(10, 20)
nn.Linear(x.size()[0], 30)