The gradient of input variables is None

Hello, everyone. I need to use the neural network in an unconventional way, in which I have to compute the gradient of the model output with respect to the input, but I always get a None.
My code is like this:

    model = torch.load('totalmodel.pth')
    x = torch.tensor([1.,2.,3.,4.],device=device,requires_grad=True)
    y = model(x)

And the output is:

It shows that the grad_fn of output y is valid, and x requires_grad is True, why is the grad of x None?

I worked this out. I detach the input when I convert the data type of the input parameters… I quit the detach and it works…