Could you explain a bit, what “gradient of a vector” means?
If you would like to calculate the gradients of all parameters (as done during training), you could just reuse the training loop and use the validation or test dataset.
Note that you should not update the model, as this would of course be a data leakage.