code: def get_tb_writer(
      tensorboard_log_dir: Optional[str],
  ) -> Optional[TBWriter]:
      try:
          if tensorboard_log_dir is not None:
              tb_writer = TBWriter(tensorboard_log_dir)
          else:
              tb_writer = None
      except ImportError:
          log.error(
              "Failed to import SummaryWriter from torch.utils.tensorboard. Failed to initialize Tensorboard "
              "logger. Install appropriate Pytorch version to use this logger or remove tensorboard_log_dir "
              "parameter from the train parameters list in the configuration file."
          )
          tb_writer = None
      return tb_writer
  
file_path: DeepPavlov/deeppavlov/core/common/log_events.py
imports: from logging import getLogger
  from typing import Optional
  from deeppavlov.core.commands.utils import expand_path
label_desc: Use image node_id 1 for calling a global function with example usage: get_tb_writer(tensorboard_log_dir) and returns: tb_writer