Which formula is used to calculate the derivative of torch.where/torch.nonzero

Hey,
I would like to know the formula behind the torch.where and torch.nonzero functions
that is used for backpropagation.

Maybe, you even have a general formula for similiar discontinous operations.

You can find the derivative for torch.where here and for torch.nonzero here, which is not differentiable as its returning indices.