Solved by mruberry in post #4 
              
              
                If you’re using PyTorch’s nightly builds (or wait until PyTorch 1.8) then we’ve added nan_to_num. See its documentation here: