Solved by nbansal90 in post #3 
              
              
                Found out the mistake in Regularizer function. Shouldn’t have declared a Variable for type requires_grad=True.Works fine after that.