At least 1 thing i’ll say is you seem to be registering the hook in a loop, this is unnecessary, you can simply register once, and keep seeing the updated glb_feature every-time you do a  forward pass, and glb_grad in backward.
After the line final_layer = net.classifier2
add the code, and dont keep the register lines in the loop.
final_layer.register_forward_hook(Get_features) final_layer.register_backward_hook(Get_grad)