I had to something like this some time ago, and I just returned the output before the linear layer i.e.
before_fc1 = fc1
output = self.fc(fc1)
return before_fc1, output 

I am guessing you have to send this feature to your loss function, in that case this may work.