It seems you are overwriting the model output in these lines:
        outputs = model(input)  
        outputs = torch.DoubleTensor(25)
        outputs = outputs.type(torch.cuda.FloatTensor)

If you create a new outputs tensor with a constant value, the computation graph will be detached and you won’t be able to update the parameters.
Could you explain a bit, why you would like to do it?
PS: I’ve formatted your code for better readability. If you want to post code snippets, you can wrap them in three backticks ```