This is a snippet of Linear layer,  as you can see.  The learnable weights are registered as Parameter which is default as requires_grad=True, see here 107.  Input of the networks needs no gradient(They are useless in most cases).   So everything is fine.
    def __init__(self, in_features, out_features, bias=True):
        super(Linear, self).__init__()
        self.in_features = in_features
        self.out_features = out_features
        self.weight = Parameter(torch.Tensor(out_features, in_features))
        if bias:
            self.bias = Parameter(torch.Tensor(out_features))
        else:
            self.register_parameter('bias', None)
        self.reset_parameters()