Solved by Rohan_Kumar in post #16 
              
              
                [Screenshot_2020-01-07 Google Colaboratory(3)] 
I think I might have solved this, if i keep everything as is and only comment out contex = Variable(context).cuda(), the grad for embedding is present. 
I think declaring the output of encoder class as Variable somehow breaks the class, am i correct?