If these are used during the computation of the loss in a differentiable manner, you can get:

call .retain_grad() on these intermediary elements so that their .grad field will be populated when you call loss.backward().
Get the grad only for these with grads = autograd.grad(loss, interm_tensors).