The grad_fn is an attribute of a tensor, which was created by a differentiable operation and which Autograd has tracked.
Here is a small example:
x = torch.randn(1)
w = torch.randn(1, requires_grad=True)
y = x * w
print(y.grad_fn)
> <MulBackward0 object at ...>