torch:grad
(torch:grad tensor)
Returns the gradient torch:backward accumulated into the tensor -- a raw linalg value of the data's shape -- or nil before any backward pass has reached it. Gradients accumulate (+=) across backward calls; torch:zero-grad clears the slot.