How did you check the gradient shape? Could you post the code snippet you were using?
If you want to create gradients for the input, you would have to set the requires_grad attribute of the input tensor to True and could check the gradient via print(input.grad) after the backward call.
The gradient would have the same shape as the input in this case.