Solved by ptrblck in post #6 
              
              
                Yes, this operation pred>threshold won’t get any gradients as you can see in the missing .grad_fn in the output, as this operation is not differentiable.