register_forward_hook takes more complex functions than lambda x: print(x) as input. Try this example.
import torch
import torch.nn as nn

class Example(nn.Module):
    def __init__(self):
        super().__init__()
        self.l1 = nn.Linear(1,3)
        self.l2 = nn.Linear(3,2)
    
    def forward(self, x):
        mid = self.l1(x)
        res = self.l2(mid)
        return res


if __name__ == "__main__":
    model = Example()
    dummy_input = torch.randn([1])
    print(dummy_input)

    def hook(module, input, output):
        print(output)
    
    model.l1.register_forward_hook(hook)
    out = model(dummy_input)