Yes, by using such an operation, you cannot calculate the gradient by usual backpropagation (because the gradient of the loss with respect to the parameter before this non-differentiable function will be zero : in your case it is all the parameters since you do it at the network output).

So either you manage to avoid this : for example reformulate your network or your loss function
Or you find other methods to estimate the gradient directly (without back-propagation) : Yoshua et al. propose something like this in the case of stochastic neural networks (Estimating or Propagating Gradients Through Stochastic Neurons for Conditional Computation)