The problem is X_fooling.grad if printed shows float32 values, but when used it shows as Nonetype and can not do anything with it. Not even .dtype. Shows X_fooling.grad is nonetype and can not do .dtype or any operations with it.