Thank you for replying!
The error is fixed
Here is the code:
from sentence_transformers import SentenceTransformer

def hook(name, output):
    #name = module.__class__.__name__
    activation[name] = output[0].detach()
activation = {}
model = SentenceTransformer('T-Systems-onsite/cross-en-de-roberta-sentence-transformer')
output = model.encode("test sentence", convert_to_tensor=True)
for name, layer in model.named_modules():
    layer.register_forward_hook(hook(name,output))
print(activation)

the output of the intermediate layers is the same.