I found a way to resolve the issue: basically reinstall pytorch and update protobuf to a newer version: Original version: protobuf 5.28.2 and pytorch 2.5.1
conda install --force-reinstall pytorch=2.5.1 protobuf=5.28.3
Now python -c 'import torch' works perfectly.