PyTorch creates a dynamic computational graph (like a tree) when calculating the gradients.
The leaves of this tree are input tensors. For leaves, you can only get the gradients if I am right.
Gradients are calculated by tracing the graph from the root (output tensor) to the leaf and multiplying every gradient in the way using the chain rule .
I created several examples in here 2.
In your example,
var_actions = torch.tensor(actions.data, requires_grad=True)

will be a leaf so this is why you are getting the gradients. In non leaf case, you will get None, as you confirmed.