How can I get the upper and lower layers of a certain layer of the model

for the visualization : Print Autograd Graph

for the hook I let you look at the doc explaining how to use it.