Let x be a scalar tensor holding value with requires_grad=True, and
let
y = x**2 + detached(x**3)
where the cubic term is detached from the graph so no gradient flows through it.
Differentiate y with respect to x and return x.grad. Since only the square
contributes, the answer is 2*value rather than 2*value + 3*value**2.
Input
2.0
Output
tensor(4.)