Solved by beaupreda in post #2 
              
              
                I believe this thread answers your question (max is an identity function for the maximum element). 
Confused about torch.max() and gradient