But this line     x = torch.exp(x)   # Want to hook this tensor in forward pass is actually executed every time the forward is called. So you can put whatever code you want next to that line and it will run during the forward.