_ContextMethodMixin.mark_non_differentiable(*args)[source]
This should be called at most once, only from inside the forward() method, and all arguments should be outputs.
This will mark outputs as not requiring gradients, increasing the efficiency of backward computation. You still need to accept a gradient for each output in backward(), but it’s always going to be a zero tensor with the same shape as the shape of a corresponding output.
This is used e.g. for indices returned from a max Function.