Hi, I coded a solution for your problem. You can check it in the link below.

  
      
      GitHub
  
  
    

Goutam-Kelam/PytorchForum 225

Contains my trials for answering the questions asked in the forum - Goutam-Kelam/PytorchForum


  
  
    
    
  
  


Hope this works out for you.