Solved by someAdjectiveNoun in post #2 
              
              
                The problem is solved. Thanks to this post and discussion between @ljj7975 & @ptrblck for hinting me towards checking if the computation graph was broken somewhere. It was exactly that. The computation graph was broken while calling loss.backward().