Fix TensorBoardCallback for older versions of PyTorch
# What does this PR do?

It looks like the olad `SummaryWriter` class from `tensorboardX` does not have all the methods of the more recent class in PyTorch, this PR just checks the method is there before using it.

Fixes #8202