This means that you tried to backward on a Tensor that does not require gradients.
This is most likely because you did a non-differentiable operation on your Tensor.
In particular, your BinaryRepresentation. The output does not depend on the input in any differentiable way.
Thank you for your pointing out my misunderstanding.
It was caused by if statement which makes the impossible to differentiate.
Now it works (but I get other error).