Ok i understood. So let say i want to extract some information from customize function and use that information for loss calculation. Can i pass the “grad_input=torch.ones(1,1,1,10) * grad_output”  instead of “grad_input[input < 0] = 0” in backward function shown in Second code for input of shape torch.ones(1,1,1,10) in forward function so that loss will backpropagate and  network will converge?.
One more thing i want to add is in forward pass i extract the information using torch commands like “torch.where” and “torch.count_nonzero” and no differentiable operation. So could i pass the gradient information of next layer you can say which is loss to previous layer?