code: def build_log_dir(cfg):
      # create base log directory
      if cfg.CONFIG.LOG.EXP_NAME == "use_time":
          cfg.CONFIG.LOG.EXP_NAME = time.strftime(
              "%Y-%m-%d-%H-%M-%S", time.localtime(time.time())
          )
      log_path = os.path.join(
          cfg.CONFIG.LOG.BASE_PATH, cfg.CONFIG.LOG.EXP_NAME
      )
      if not os.path.exists(log_path):
          os.makedirs(log_path)
  
      # setup log file and stdout
      logger = logging.getLogger("gluoncv")
      log_level = logging.getLevelName(cfg.CONFIG.LOG.LEVEL)
      plain_formatter = logging.Formatter(
          "[%(asctime)s] %(name)s %(levelname)s: %(message)s",
          datefmt="%m/%d %H:%M:%S",
      )
      logger.setLevel(log_level)
      logger.propagate = False
      # file logger, enabled for all workers
      log_filename = os.path.join(log_path, cfg.CONFIG.LOG.LOG_FILENAME)
      if cfg.DDP_CONFIG.WORLD_RANK > 0:
          log_filename += f".rank{cfg.DDP_CONFIG.WORLD_RANK}"
      fh = logging.StreamHandler(_cached_log_stream(log_filename))
      fh.setLevel(log_level)
      fh.setFormatter(plain_formatter)
      logger.addHandler(fh)
      if cfg.DDP_CONFIG.WORLD_RANK == 0:
          # stdout in rank 0 only
          ch = logging.StreamHandler(stream=sys.stdout)
          ch.setLevel(log_level)
          logger.addHandler(ch)
  
      # dump config file
      with open(os.path.join(log_path, "config.yaml"), "w") as f:
          f.write(cfg.dump())
  
      # create tensorboard saving directory
      tb_logdir = os.path.join(log_path, cfg.CONFIG.LOG.LOG_DIR)
      if not os.path.exists(tb_logdir):
          os.makedirs(tb_logdir)
  
      # create checkpoint saving directory
      ckpt_logdir = os.path.join(log_path, cfg.CONFIG.LOG.SAVE_DIR)
      if not os.path.exists(ckpt_logdir):
          os.makedirs(ckpt_logdir)
  
      return tb_logdir
  
imports: import os
  import sys
  import time
  import functools
  import logging
  from contextlib import contextmanager
  from functools import wraps
  import numpy
  import torch.nn
  import torch
label_desc: Use image node_id 3 for calling a global function with example usage: build_log_dir(cfg) and returns: tb_logdir