@albanD, I finally found the issue!
I have used tensorboard for logging during training, I use this repository TensorFlowLog  to export the logs. If I do a relative import of TensorFlowLog from the main.py everything is fine, however if I do a relative import of the same module from another file in another directory it creates problems. For another directory I mean a directory in the project  but not  a child directory of the main.py.
Simply, absolute import of TensorFlowLog  solved the issue!
EDIT: it actually did not solve the issue. I accidentally remove some lines during debugging. The issue is still present. My workaround is to import tensorboard.backend.everything at the very last part of the code, I really hate this solution but found nothing better.
This bug, I think, was hard to detect: 1 failing silently during the importing phase, 2 generating “floating point error” during training, which seems completely unrelated to the actual issue.
After little experience, I think that tensorboard is very buggy in my setup. I was thinking maybe It would be better to manually  save logs by incrementally update a dataframe and save as it csv. I just need to to save some scalars.
What could be for you a simple and clean way to save training logs?(Loss, accuracy, validation…)
Thanks so much,
Stefano